Jquery Ajax instance 5: send a request to WebService to return the asynchronous data of a generic set

Source: Internet
Author: User

1. WebService. asmx:
The GetList method generates generic set data for JqueryRequest. aspx to call. The Code is as follows:

[WebMethod]
Public List <string> GetList ()
{
List <string> list = new List <string> ();
List. Add ("aaaaaaaaaaaa ");
List. Add ("bbbbbbbbbbbbbb ");
List. Add ("cccccccccccc ");
List. Add ("dddddddddddd ");
Return list;
}

Ii. AjaxRequest. aspx

Click the button to request the GetList () method of WebService. asmx to obtain the generic set. The Code is as follows:

<Script type = "text/javascript" language = "javascript">
Function BtnList_Click (){
$. Ajax ({
Url: "aa. asmx/GetList ",
Data :{},
Type: "post ",
Success: function (data, status ){
Var str = "";
Try {
Var obj = $ (data. xml );
Var vals = obj. find ("string ");
$. Each (vals, function (index, item ){
Str + = $ (item). text () + "<br/> ";
});

$ ("# Dd" pai.html (str );
}
Catch (ex ){
Alert (ex );
}
}
});
}
</Script>

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.