我有这样的代码:
$.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,知道为什么成功处理程序不会触发吗?
发布于 2016-06-27 14:18:14
这是有效的JSON:
{"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}
但这并不是:
数组(7){ "product_id"=>字符串(1) "5“=>字符串(2) "85”条件“=> string(8)”"ovp1"=> string(1) "0“"ovp2"=> string(1) "0”"ovp3"=> string(1) "0“"ovp4"=> string(1) "0”{“full_price”}{“full_price”,"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}
看起来服务器使用的是PHP,在打印JSON的语句之前有一个print_r。
https://stackoverflow.com/questions/38056295
复制相似问题