1 allows serialization of nested parameters. For example: {foo: ["bar", "baz"]} will be serialized into foo[]=bar&foo[]=baz, instead of serialized into the previous foo=bar&foo=baz.
If you want to use the old serialization method, there are three settings:
jQuery.ajaxSettings.traditional = true;
jQuery.param( stuff, true );
$.ajax({ data: stuff, traditional: true });
2 Automatically detect the data types of json and javascript. After 1.4, it is no longer necessary to set the dataType when returning json or javascript. The type will be automatically determined based on application/json or application/x-javascript. However, the data type returned by the background must be specified.
3 supports adding html header information.
$.ajax() adds a new attribute ifModified: true, set to true, which can effectively utilize the browser cache (I have tried its effect so far.)
4 Use native JSON.parse , to parse json.
1.4 will verify the legality of json returned by ajax, and incorrect json format will not be parsed, such as {foo: "bar"}.
5 When $.serialize() serializes the form, html5 form elements can now be serialized.
...it keeps pace with the times, I haven’t looked at html5 seriously yet...
6 Pay attention to the new attribute Context, which is very useful
The emergence of Context is so timely ,Context will simplify your ajax request. The function of Context is that you can customize the context, that is, specify this of the callback function in ajax. Let’s look at the code:
jQuery.ajax({
url: "test.html",
context: document.body,
success: function(){
jQuery(this).addClass("done");
}
}) ;
This in the code success callback function will point to document.body
7 Explicitly set content-type
Before 1.4, if you did not set the parameter data, $ .ajax() will ignore the value of the contentType parameter. 1.4contentType must be sent during an ajax request.
8 You can specify the callback function name of JSONP
9 Cross-domain requests are not allowed by default