Simple jquery ajax example (interface + background)

Source: Internet
Author: User

Interface:
Copy codeThe Code is 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:" + data + "\ n status:" + status );
});
});
});

$ (Document). ready (function (){
$ ("# Postbutton"). click (function (){
$. Get ("/CustomerInformation/getS", {par: "ww"}, function (data, status ){
Alert ("data:" + data + "\ n status:" + status );
$ ("# PostText" pai.html (data );
});
});
});

</Script>
<Div id = "div04">
<H2 id = "postText"> after the post method loads the text, it is displayed here <Input type = "button" value = "post method" id = "postbutton"/>
</Div>

<Div id = "div03">
<H2 id = "getText"> after the get method loads the text, it is displayed here <Input type = "button" value = "get method" id = "getbutton"/>
</Div>

<Div id = "div02">
<H2> display of jquery load method loading here <H2 id = "test"> the loaded text is displayed here </Div>

<Div id = "div01">
<H2> the loaded text is displayed here </Div>
<P>
<Input type = "button" value = "loading text" id = "b01"/>
</P>

Background:
Copy codeThe Code is as follows:
Public string getS (string par)
{
String content = "";
If (par. Equals ("ww "))
{
Content = "cheng gong le ";
}
Else
{
Content = "shi bai le ";
}
Return content;
}

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.