Jquery ajax, jquery

Source: Internet
Author: User

Jquery ajax, jquery

1. You can set global attributes, which will be simple to call later.

JQuery. ajaxSetup () code:

        
$.ajaxSetup({ url: "/xmlhttp/", global: false, type: "POST"});$.ajax({ data: myData });

Set global AJAX default options

 

Ii. jquery ajax full Parsing

Jquery ajax full parsing-parameter description

Jquery ajax full parsing-$. post ()

Jquery ajax full parsing-jQuery. getScript (url, [callback]): load and execute a JavaScript file using GET requests.

Jquery ajax full parsing-serialize () and serializeArray ()


Jquery ajax usage

JQUERY:
$. Ajax ({
Type: 'post', // optional get
Url: 'action. php', // The php program that receives data.
Data: 'Data = 'dsa ', // data transmitted to PHP. Use & to connect multiple parameters.
DataType: 'text', // the data type returned by the server can be XML or Json jsonp script html text.
Success: function (msg ){
// Here is the data processing function returned by the PHP program after ajax is submitted successfully. Msg is the returned data. The data type is defined in the dataType parameter!
},
Error: function (){
Processing Function for ajax submission failure!
}
})

PHP action. php
<? Php
Echo "this is a ajax example! ";
?>

Jquery ajax usage

JQUERY:
$. Ajax ({
Type: 'post', // optional get
Url: 'action. php', // The php program that receives data.
Data: 'Data = 'dsa ', // data transmitted to PHP. Use & to connect multiple parameters.
DataType: 'text', // the data type returned by the server can be XML or Json jsonp script html text.
Success: function (msg ){
// Here is the data processing function returned by the PHP program after ajax is submitted successfully. Msg is the returned data. The data type is defined in the dataType parameter!
},
Error: function (){
Processing Function for ajax submission failure!
}
})

PHP action. php
<? Php
Echo "this is a ajax example! ";
?>

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.