Home > Article > Web Front-end > jquery's ajax asynchronous request receives and returns json data instance_jquery
jquery's asynchronous ajax request receiving and returning json data method is simple to set up. One is that the server handler returns json data, and the other is that the datatype of the ajax sending setting is set to jsonp format data or json format Both Can.
The code example is as follows:
Copy code
$.ajax({options});
url: (string) The address to send the request, which can be a server page or a WebService action.type: (string) request method, POST or GET
data: (object) data brought when sending a request to the server. It is in the form of key:value pair, such as: {name:"grayworm",sex:"male"}, if it is an array {works:["work1","work2"]}dataType: (string) expected return Data type. xml, html, json, text, etc.
beforeSend: (Function) is triggered before sending an ajax request. If false is returned, the request will be canceled. If the asynchronous request needs to display gif animation, the visibility of the corresponding should be set here.