我仍在学习 JSON,所以当我尝试这样做时,名称没有出现。
index.php :
$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";
$myJSON = json_encode($myObj);
echo $myJSON;
header("Content-Type: text/html");
index.html :
$(document).ready(function() {
$("input").blur(function() {
var data = "pName=" + $(this).val();
//alert($(this).val());
$.ajax({
type: "POST",
url: "index.php",
data: data,
success: function (respond) {
var JQuery = JSON.parse(respond);
$("#result").html('');
$("#result").append(JQuery.name);
}
});
});
});
1:
答案 0 :(得分:0)
试试这个代码。
试试这个代码。你忘记声明对象了。 $myObj = new stdClass();
<?php
$myObj = new stdClass();
$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";
$myJSON = json_encode($myObj);
header("Content-Type: text/html");
echo $myJSON;
?>
答案 1 :(得分:0)
改变
SELECT
(select ( select Sum(T_No) where Transactions = R) - (select Sum(T_No) where Transactions = D) as C_T )
FROM CustomerTrans WHERE C_T > 0 ;
到
header("Content-Type: text/html");
答案 2 :(得分:0)
谢谢大家,终于成功了<3
$myObj = new stdClass();
$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";
$myJSON = json_encode($myObj);
header("Content-Type: text/html");
echo $myJSON;
exit();