First, Webservice.asmx:
Processing business data, generating generic collection data in the GetList method for jqueryrequest.aspx invocation, with the following code:
[WebMethod]
Copy Code code as follows:
Public list<string> getlist ()
{
list<string> list = new list<string> ();
List. ADD ("aaaaaaaaaaaa");
List. ADD ("bbbbbbbbbbbb");
List. ADD ("CCCCCCCCCCCC");
List. ADD ("dddddddddddd");
return list;
}
Second, ajaxrequest.aspx
Get the generic collection by clicking the button to request the Webservice.asmx GetList () method. The code is as follows:
Copy Code code 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"). html (str);
}
catch (ex) {
alert (ex);
}
}
});
}
</script>