jquery $.ajax Instance Details simple

Source: Internet
Author: User
Tags php tutorial

This article tells you to use the $.ajax to interact with the database tutorial or asynchronous transmission of data, update data, delete data, etc. using the jquery Ajax to the example is very convenient, a few simple code on the OK.
Load JS
$.ajax ({
Type: "Get",
URL: "Test.js",
DataType: "Script"
});

Ajax Save Data
$.ajax ({
Type: "Post",
URL: "some.php tutorial",
Data: "Name=john&location=boston",
Success:function (msg) {
Alert ("Data saved:" + msg);
}
});

Ajax Save data Return value change HTM content

$.ajax ({
URL: "Test.html",
Cache:false,
Success:function (HTML) {
$ ("#results"). Append (HTML);
}
});

Load data synchronization. To prevent browser requests from being activated. Synchronization is necessary when the user's interaction is prevented by other means

var html = $.ajax ({
URL: "some.php",
Async:false
}). responsetext;

Example: An XML document sent to the server as data. Automatically converting data to strings can be avoided by setting the ProcessData option to false.

var xmldocument = [create XML document];
$.ajax ({
URL: "page.php",
Processdata:false,
Data:xmldocument,
Success:handleresponse
});

To send data to the server ID, save some data to the server and notify the user once it's done. Note that this usage-returns the result of the call to a variable-requires synchronization (blocking) of the request! (Asynchronous: false)

Bodycontent = $.ajax ({
      URL: "script.php",
      Global:false,
      type: "Post",
      data: ({ID: This.getattribute (' id ')},
      datatype: HTML,
      Async:false,
      success:function (msg) {
          alert (msg);
     }
  }
). responsetext;

Related Article

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.