We can retrieve information from the server without requiring a page refresh by calling one of these Ajax methods.
Issuing requests
Issuing requests
Ajax method |
Description |
$.ajax([url], options) |
Makes an Ajax request using the provided set of options. This is a low-level method that is often called via other convenience methods. |
.load(url, [data], [callback]) |
Makes an Ajax request to url and places the response into the matched elements. |
$.get(url, [data], [callback], [returnType]) |
Makes an Ajax request to url using the GET method. |
$.getJSON(url, [data], [callback]) |
Makes an Ajax request to url, interpreting the response as a JSON data structure. |
$.getScript(url, [callback]) |
Makes an Ajax request to url, executing the response as JavaScript. |
$.post(url, [data], [callback], [returnType]) |
Makes an Ajax request to url using the POST method. |
Request monitoring
Request monitoring
Ajax method |
Description |
.ajaxComplete(handler) |
Binds handler to be called when any Ajax transaction completes. |
.ajaxError(handler) |
Binds handler to be called when any Ajax transaction completes with an error. |
.ajaxSend(handler) |
Binds handler to be called when any Ajax transaction begins. |
.ajaxStart(handler) |
Binds handler to be called when any Ajax transaction begins, and no others are active. |
.ajaxStop(handler) |
Binds handler to be called when any Ajax transaction ends, and no others are still active. |
.ajaxSuccess(handler) |
Binds handler to be called when any Ajax transaction completes successfully. |
Configuration
Configuration
Ajax method |
Description |
$.ajaxSetup(options) |
Sets default options for all subsequent Ajax transactions. |
$.ajaxPrefilter([dataTypes], handler) |
Modifies the options on each Ajax request before it is processed by $.ajax(). |
$.ajaxTransport(transportFunction) |
Defines a new transport mechanism for Ajax transactions. |
Utilities
Utilities
Ajax method |
Description |
.serialize() |
Encodes the values of a set of form controls into a query string. |
.serializeArray() |
Encodes the values of a set of form controls into a JavaScript data structure. |
$.param(obj) |
Encodes an arbitrary object of key-value pairs into a query string. |
$.globalEval(code) |
Evaluates the given JavaScript string in the global context. |
$.parseJSON(json) |
Converts the given JSON string into a JavaScrit object. |
$.parseXML(xml) |
Converts the given XML string into an XML document. |
$.parseHTML(html) |
Converts the given HTML string into a set of DOM elements. |
关于作者:楠溪江人,出生于1991年,目前坐标上海。读书时代跳过级、保过送,工作后转过行。2013年本科毕业于北药。看书、码字、敲代码、打羽毛球是我花时间的爱好。曾在某上市药企任国际药品注册岗,现在某高新企业任前端管理岗。