$.post("sql/customer_save.php",{ what: "edit",customer_no: $customer_no},function(resp)
{
//resp is your response
//You can try
console.log(resp);
console.log(resp["customer_id"]); //get the value of customer_id
console.log(resp["customer_no"]); //get the value of customer_no
},"json");
或
您還可以使用
$.post("sql/customer_save.php",{ what: "edit",customer_no: $customer_no},function(resp)
{
//resp is your response
//You can try
var data = $.parseJSON(resp);
console.log(data);
console.log(data["customer_id"]); //get the value of customer_id
console.log(data["customer_no"]); //get the value of customer_no
});
Amirali:如果你想知道什麼不同......在'$。員額加入一個' 「JSON」'參數'電話。這告訴jQuery期待JSON形成的響應。 – Wireblue
是否有任何方法可以分別獲取每個字段?像customer_id,customer_no? –
以這種方式訪問它們,resp.customer_id和resp.customer_no – Floricel