Why is the error method executed after jQueryjsonp is successfully used for cross-origin? The Code is as follows: HTML part {code ...} PHP file (test. php) {code ...} in addition, I hope that the front-end experts can answer the question. the code for executing the error method after jQuery jsonp cross-origin is successful is as follows:
HTML section
$. Ajax ({type: 'get', ype: 'jsonp', url: "http://XXXX.com/test.php? Jsoncallback = success_jsonpCallback ", // call the custom function success: function (msg) {alert (msg) ;}, error: function (msg) {alert (123 ); alert (msg) ;}}); function success_jsonpCallback (result) {alert (result. img_url );}
Php file (test. php)
$data['status'] = "1";$data['img_url'] = "http://www.baidu.com/img/baidu_jgylogo3.gif";$jsoncallback = $_GET['jsoncallback'];//var_dump($_GET['jsoncallback']);echo $jsoncallback."(".json_encode($data).")";
In addition, I hope that the front-end experts can answer the question.
Reply content:
The code for executing the error method after jQuery jsonp cross-origin is successful is as follows:
HTML section
$. Ajax ({type: 'get', ype: 'jsonp', url: "http://XXXX.com/test.php? Jsoncallback = success_jsonpCallback ", // call the custom function success: function (msg) {alert (msg) ;}, error: function (msg) {alert (123 ); alert (msg) ;}}); function success_jsonpCallback (result) {alert (result. img_url );}
Php file (test. php)
$data['status'] = "1";$data['img_url'] = "http://www.baidu.com/img/baidu_jgylogo3.gif";$jsoncallback = $_GET['jsoncallback'];//var_dump($_GET['jsoncallback']);echo $jsoncallback."(".json_encode($data).")";
In addition, I hope that the front-end experts can answer the question.
Error handler is an Ajax Event.
This handler is not called for cross-domain script and cross-domain JSONP requests.
We recommend that you use the jsonp and jsonpCallback parameters.