jquery Ajax Simple Example (interface + background) _jquery

Source: Internet
Author: User
Interface:
Copy Code code as follows:

<script>
$ (document). Ready (function () {
$ ("#b01"). Click (function () {
Htmlobj = $.ajax ({URL: "/content/upfile/test. txt", async:false});
$ ("#div01"). HTML (htmlobj.responsetext);
});
});

$ (document). Ready (function () {
$ ("#test"). Load ("/content/upfile/test 2.txt #p1", function (Responsetxt, statustxt, XHR) {
if (Statustxt = = "Success")
Alert ("External content loaded successfully!") "+ XHR);
if (Statustxt = = "Error")
Alert ("Error:" + xhr.status + ":" + xhr.statustext);
});
});

$ (document). Ready (function () {
$ ("#getbutton"). Click (function () {
$.get ("/downset/index", function (data, status) {
Alert ("Data:" + date + "\ n State:" + status);
});
});
});

$ (document). Ready (function () {
$ ("#postbutton"). Click (function () {
$.get ("/customerinformation/gets", {par: "ww"}, function (data, status) {
Alert ("Data:" + date + "\ n State:" + status);
$ ("#postText"). HTML (data);
});
});
});

</script>
<div id= "DIV04" >
&LT;H2 id= "PostText" >post method will be displayed here after the download of the <input type= "button" value= "Post method gets" id= "Postbutton"/>
</div>

<div id= "div03" >
&LT;H2 id= "GetText" >get method will be displayed here after the download of the <input type= "button" value= "Get Method gets" id= "Getbutton"/>
</div>

<div id= "Div02" >
The &LT;H2 id= "Test" will be shown here </div>

<div id= "DIV01" >
</div>
<p>
<input type= "button" value= "Loaded" id= "B01"/>
</p>

Background:
Copy Code code as follows:

public string GetS (string par)
{
String content = "";
if (par. Equals ("ww"))
{
Content = "Cheng gong le";
}
Else
{
Content = "Shi bai le";
}
return content;
}
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.