Four ways Ajax asynchronously invokes in JQuery _jquery

Source: Internet
Author: User
<script type= "Text/javascript" language= "JavaScript" src= "Js/jquery-1[1].2.3.min.js" ></script> < Script type= "Text/javascript" language= "JavaScript" > $ (document). Ready (function () {//jquery page load event, This method is first executed after the page is loaded//the first Ajax request $.ajax ({type: "get",///request type, with get,post type, and form submission is the same URL: "result.aspx",//Request processing page, that is, the page to capture the request, the same path can be replaced by ASHX, general handler data: "Name=john&location=boston",//Transfer parameters, is really (Result.aspx?name=john
    &loaciton=boston) success:function (msg) {//The success of the request is handled by this method, where the request for a successful return value is received by MSG $ ("#ajaxDIV"). Text (msg);
  
  
  }
  }); The second request $.get (////Get request method, in fact, is the variant of the previous one "Handler.ashx", {name: "Stupid Bear", sex: "Female"},///To pass the parameter, parse to (Handler
    . ashx?name= Bear &sex= Female) function (msg) {//Request return parameter $ ("#Div1"). Text (msg);
  
  }
  ); The third request $.post (//The previous one of this request is the same, but the request is different "handler2.ashx", {name: "Benben stupid Bear", sex: "Female"}, function (msg)
    {$ ("#Div2"). Text (msg);
  
  
  }
  ); The fourth kind of request $.getJSON (//This is implemented in JSON, JSON is a generic data format "HANDLER3.ASHX",//path {name: "AAA"},///pass parameter function (data) {     The callback processing function returns the JSON data format, which receives the data var str= "";
      The following is the analysis of these data, the use of specific transfers but do not consider, the design of a lot of content, temporarily unable to explain str+= "name:  " +data.name+ "<br/>";
      str+= "Sex:  " +data.sex+ "<br/>";
      str+= "Address:  " +data.address+ "<br/>";
    $ ("#Div3"). html (str);
}
  );
}); </script>

The above is the entire contents of this article, learn more jquery syntax, you can see: "JQuery 1.10.3 Online Handbook", also hope that we support the cloud-dwelling community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.