Methods Basics Jquery -3-jQuery Ajax operations carried out

A method of operation jQuery for Ajax
. 1, load () method load () method is the simplest and most common method of Ajax, HTML code can be loaded remotely and insert the DOM.
◆ Syntax: load (url, [data] , [callback])

 

 

 


. 2, $ get () method by remote HTTP GET request load information
◆ syntax:. $ Get (url, [ data], [callback], [type])

Chinese garbled solution to the problem:

XML data transfer:

JSON data transfer:

 

 

 


3, $. Post () method
◆ HTTP POST request by remote loading information.
◆ it $ .get () method of substantially the same structure and use.
4, get and post requests requesting the difference

◆ GET request with the parameters passed in the URL, and HTTP POST request as a request entity content is sent to the server. In the Ajax request, these differences are not visible to the user.
◆ GET method is limited in size (typically no greater than 2KB) of data transmission, and a large plurality of data passed by either GET POST method.
◆ GET request to the way data is cached by the browser, so other people can read through the browser history of these data, such as passwords, etc., so there will be security issues GET requests, but POST relatively avoided these questions.

 


5, $. GetScript () method via HTTP GET 

Request Load and execute a JavaScript file
◆ Syntax:. $ GetScript (url, [ callback])

json on the network:

 


6、$.getJson()方法 通过HTTP GET 请求载入 JSON 数据
◆ 语法:$.getJSON(url, [data], [callback])


7、aJax()方法$.ajax()方法是jQuery最底层的Ajax实现。前面所讲的哪些操作ajax的方法都是基于$.ajax()方法构建
的,因此此方法可以替换前面的所有方法。
◆ 语法:$.ajax(url,[settings])

8、$.aJax()常用的请求参数:
◆type:设置请求方式,主要是GET和POST,默认是GET
◆timeout:设置请求超时时间
◆data:发送到服务器的数据。
◆dataType:预期服务器返回的数据类型,比如:xml、json、text等。
9、$.aJax()常用的请求参数:
◆beforeSend:发送请求前可以修改XMLHttpRequest对象的函数,例如添加自定义HTTP头信息等。
◆complete:设置完成后调用的回调函数,请求失败均会调用。

◆success:请求成功后调用的回调函数
◆error:请求失败后被调用的函数。
◆global:默认为true,表示是否触发全

 

Guess you like

Origin www.cnblogs.com/HiJackykun/p/11204059.html