Javascript 为什么';在这种情况下,jquery是否调用成功处理程序?
我有以下代码:Javascript 为什么';在这种情况下,jquery是否调用成功处理程序?,javascript,jquery,json,post,Javascript,Jquery,Json,Post,我有以下代码: $.post( "/ankauf/", { "kunden_id" : 1, "products" : products, "full_price" : parseInt($('#totalPrice').text()), "_token" : $('meta[name="csrf-token"]').attr('content') }, function( data ) {
$.post( "/ankauf/", {
"kunden_id" : 1,
"products" : products,
"full_price" : parseInt($('#totalPrice').text()),
"_token" : $('meta[name="csrf-token"]').attr('content')
},
function( data ) {
toastr.success("Ankauf abgeschlossen", "OK!");
}
);
它向我的服务器发出post请求,就像我在应用程序中经常做的那样
Chrome显示此请求如下:
Request Method:POST
Status Code:200 OK
Remote Address:192.168.178.80:1414
响应如下所示:
Cache-Control:no-cache
Connection:close
Content-Type:application/json
Response content:
array(7) {
["product_id"]=>
string(1) "5"
["paidprice"]=>
string(2) "85"
["condition"]=>
string(8) "Sehr Gut"
["ovp1"]=>
string(1) "0"
["ovp2"]=>
string(1) "0"
["ovp3"]=>
string(1) "0"
["ovp4"]=>
string(1) "0"
}
{"full_price":"85","updated_at":"2016-06-27 14:01:55","created_at":"2016-06-27 14:01:55","id":73,"created_by_id":1,"customer_id":1}
因此,服务器响应看起来像是一个有效的JSON响应,http代码是200。您知道为什么成功处理程序没有启动吗?这是一个有效的JSON:
但这不是:
看起来服务器正在使用PHP,在打印JSON的语句之前有一个print\r
。这是有效的JSON:
但这不是:
看起来服务器正在使用PHP,在打印JSON的语句之前有一个
print\r
。PHP代码中有一个var\u转储。我以为这是chrome开发者工具格式化的东西。谢谢你的帮助。将在8分钟后接受。php代码中有一个var_转储。我以为这是chrome开发者工具格式化的东西。谢谢你的帮助。将在8分钟内接受。
{"full_price":"85","updated_at":"2016-06-27 14:01:55","created_at":"2016-06-27 14:01:55","id":73,"created_by_id":1,"customer_id":1}
array(7) {
["product_id"]=>
string(1) "5"
["paidprice"]=>
string(2) "85"
["condition"]=>
string(8) "Sehr Gut"
["ovp1"]=>
string(1) "0"
["ovp2"]=>
string(1) "0"
["ovp3"]=>
string(1) "0"
["ovp4"]=>
string(1) "0"
}
{"full_price":"85","updated_at":"2016-06-27 14:01:55","created_at":"2016-06-27
14:01:55","id":73,"created_by_id":1,"customer_id":1}