Add the following code in the PHP file
Specifies that other domain names are allowed to access the header (' access-control-allow-origin:* '); Response type header (' Access-control-allow-methods:post '); Response header Set header (' Access-control-allow-headers:x-requested-with,content-type ');
PHP page output is in the following format
echo "success_jsonpcallback(". Json_encode ($my _array) ")";
Ajax needs to make the following modifications
$.ajax ({ "post", "ajax.php", "Jsonp", "callback",// the parameter name passed to the request handler or page to obtain the name of the JSONP callback function (default: Callback) jsonpcallback: "success_jsonpcallback ",// function(JSON) { alert (' success '); } , error:function() { alert (' fail '); }});
Note that the red part corresponds to the parameter value returned by PHP above
Ajax solves cross-domain issues