Make a jsonp request
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>test</title> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajax({ type: "get", async: false, url: "http://encounter.christmas023.space/json.php?name=mavis&age=18", dataType: "jsonp", jsonp: " callback " , // The parameter name passed to the request handler or page to get the name of the jsonp callback function (generally default: callback) jsonpCallback: " message " , // The name of the custom jsonp callback function, The default is the random function name automatically generated by jQuery, you can also write "?", jQuery will automatically process the data for you success: function (json){ alert( ' your name: ' + json.name + ' age: ' + json.age); }, error: function(){ alert('fail'); } }); }); </script> </head> <body> </body> </html>
http://www.jb51.net/article/103960.htm jsonp returns data style, request method, very comprehensive!