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>