Home  >  Article  >  Web Front-end  >  3 request methods of jQuery $.post, $.get, $.getJSON_jquery

3 request methods of jQuery $.post, $.get, $.getJSON_jquery

WBOY
WBOYOriginal
2016-05-16 16:54:091108browse

$.post, $.get, $.getJSON are the three request methods of jQuery

1. $.get is the get method to submit data, usage: $.get(url,data,callback), for example:

Copy code The code is as follows:

$.get("../saveUser.action" ,{
'userId':123,
'userCode':'123'
},function(data)){}

2. $.post is post submission , generally speaking, it is relatively safe, usage: $.post(url,data,callback), example:
Copy code The code is as follows:

$.post("../saveUser.action",{
'userId':123,
'userCode':'123'
}, function(data)){}

3. $.getJSON is also submitted according to the get method, but $.getJSON supports cross-domain, and its usage is basically the same as $.get and $.post $.get(url,data,callback), example:
Copy code The code is as follows:

$.getJSON("../saveUser.action?callback=?",{
'userId':123,
'userCode':'123'
},function(data)){}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn