$. Ajax ({type: "Get", URL: "Services/efservice. SVC/members ", data:" {} ", contenttype:" application/JSON; charset = UTF-8 ", datatype:" JSON ", success: function (data) {// play with returned data in JSON format}, error: function (MSG) {alert (MSG) ;}}); a global event is triggered by each Ajax request, it broadcasts all elements to the Dom. The script loaded in the preceding getscript () example is a global Ajax event. Global events can be defined as follows: $ ("# loading "). ajaxstart (function () {$ (this ). show () ;}); you can disable global events in specific requests. You only need to set the global option: $. ajax ({URL: "test.html", Global: false, // disable global Ajax events. //...}); the following is a complete list of Ajax events officially provided by jquery: • ajaxstart (Global Event) This event is broadcast if an Ajax request is started and no other Ajax requests are currently running. • beforesend (local event) this event, which is triggered before an Ajax R Equest is started, allows you to modify the XMLHTTPRequest object (setting additional headers, if need be .) • ajaxsend (Global Event) this global event is also triggered before the request is run. • Success (local event) This event is only called if the request was successful (no errors from the server, no errors with the data ). • ajaxsuccess (Global Event) This event is also only called if the request was Successful. • error (local event) This event is only called if an error occurred with the request (you can never have both an error and a success callback with a request ). • ajaxerror (Global Event) this global event behaves the same as the local error event. • Complete (local event) This event is called regardless of if the request was successful, or not. you will always receive a complete callback, even For synchronous requests. • ajaxcomplete (Global Event) This event behaves the same as the complete event and will be triggered every time an Ajax request finishes. • ajaxstop (Global Event) this global event is triggered if there are no more Ajax requests being processed. jquery. ajaxsetup (options): sets the global Ajax default options. Set the default address of an Ajax request to "/XMLHTTP/". Do not trigger a global Ajax event. Use post instead of the default get method. No option parameters are set for subsequent Ajax requests. Jquery code: $. ajaxsetup ({URL: "/XMLHTTP/", Global: false, type: "Post"}); $. ajax ({data: mydata}); if it is specified as HTML, any embedded Javascript will be executed before HTML is returned as a string. Similarly, if the script type is specified, the server will first generate JavaScript and then return the script as a text data. JSON data is a structured data that can be easily parsed using JavaScript. If the obtained data file is stored on a remote server (the domain name is different, that is, cross-Origin data retrieval), The jsonp type is required. If this type is used, a query string parameter callback =? will be created? This parameter is added after the request URL. The server should add the callback function name before the JSON data to complete a valid jsonp request. If you want to specify the callback function parameter name to replace the default callback, you can set the jsonp parameter of $. Ajax.
$. Ajax usage