Ajax is used to create asynchronous web applications. It is deployed on the client-side and makes use of several web technologies.
Ajax has made it easier to asynchronously send and retrieve data from a server without interfering with the existing page’s display and functionality.
Ajax is not a programming language, and it requires a built-in browser with XMLHttpRequest object, which requests data from the server. It also uses JavaScript and HTML DOM to display the data.
Ajax data refers to the data that will be sent to the server. The data is of type Plain object, string, or an array.
If the HTTP method does not have an entity-body, such as
GET
, this data is appended to the URL.
Since data is an object, unless the processData
is set to false
, jQuery generates a data string from the objects’ key/value pairs
.
For example, {a: "b,c", d: "e,f", x:"qv"}
is converted to a string, "a=b%2Cc&d=e%2Cf&x=qv"
If the value is an array, jQuery serializes multiple values with the same key and links them to a single value. For example:
{ a: [5,9] }
is converted to a string "a%5B%5D=5&a%5B%5D=9"
with the default traditional: false setting.
When data is passed as a string, it should be ensured that it is already encoded using the correct encoding for contentType
, i.e., application/x-www-form-urlencoded.
If the datatype is json
or jsonp
, any single ("?") or double ("??") in the query string are replaced by a single value generated by jQuery. It then uniquely identifies each library on the page. For example, jQuery??
can be converted to:
jQuery21406249345565963422229067_14790230232745
RELATED TAGS
CONTRIBUTOR
View all Courses