Solve, how to solve it? Another domain name walk is OK, but this domain name does not go, front-end code is as follows:
The backend code is as follows:
Reply content:
Solve, how to solve it? Another domain name walk is OK, but this domain name does not go, front-end code is as follows:
The backend code is as follows:
Interface didn't deal with callback, right?
There is no error in the notation, it is estimated that the server side returned is not a jsonp
format, callback processing failed.
$.ajax The default jsonp
callback parameter is ?callback=_XXXX
to see if background processing and return are correct.
The value of the server return is wrong yes, you're returning a null value. Look, what if there {"result":"successful"}
's something like that?
Javascript: Adding
$.ajax({ .... jsonp:'jsonp_callback', <- 指定callback回调函数名 ....})
jquery uses Ajax get to request a /url/?callback=jsonp_callback
URL
The JavaScript callback that will then be executed jsonp_callback(result)
function(){ return string;}
JavaScript receives a string-type output. is not JSON. It's not the JSON that die.
function (){ // 这里是callback还是jsonp_callback忘了。具体百度一下 return $_GET['callback']."(".json_encode($string).")"; // 实际返回并输出的将会是: `jsonp_callback("string")`}
Update
Look at the words:
The AJAX request address ishttp://baidu.com
The actual request address ishttp://baidu.com/?callback=xxxxxxx&_=xxx&_=xxxx
Why not use numbers instead of returning content?
DataType does not match the return value, it is recommended to remove this parameter so that jquery automatically recognizes the return value.
Besides, it's not jsonp, is it?