Home  >  Article  >  Web Front-end  >  Simple examples of get and post in jquery_jquery

Simple examples of get and post in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 17:01:291049browse

Example:

test.html
Page reference


The following is a function taken from the network:

The post method is as follows:

Copy code The code is as follows:

function test(access_url, tipE){

$.post(access_url,{
first: "test1", second: "test2"
}, function(data){
if(data.success){
               $(' #' tipE).html('Processed successfully'); 🎜>          },'json'
) )
}


If you want to use the get method, just replace post with get. It’s quite simple!

The data value in this function is the value returned by the server and is in JSON format. Of course, other types can be used here, such as text, xml, etc.


The return value from the server is in JSON format, such as: {success:true, msg:"Test successful"}
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
Previous article:21 Javascript tips worth collecting_javascript tipsNext article:21 Javascript tips worth collecting_javascript tips

Related articles

See more