Calling WebService via Ajax.NET

Source: Internet
Author: User

<asp:scriptmanager id= "ScriptManager1" runat= "Server" >
<asp:servicereference path= "Webservice.asmx"/>


-------------------WebService1 -----------------------------
To allow the Web service to be called from the script using ASP. NET AJAX, uncomment the downstream.

The method in the webservice is called by the interface by means of a method marked with [WebMethod].
Public Class WebService1 : System.Web.Services.WebService
Public List<string> GetList()
List<string>List= New List<string>();
List.Add("Wang Yi");
<HTML xmlns="Http://">

<script src= "js/Jquery1.7.js"Type="Text/Javascript"></script>
<script type= "Text/Javascript">
$ (function () {
$ (' #Button1 '). Click (function () {
$.ajax ({
Type: "Post",
ContentType: "Application/Json",
URL: "WebService1.asmx/GetList",//visit the local WebService service here/can access the HTTP
Data: "{}",
Success:function (Result) {
var str = ';
for (var i = 0; i < result.d.length; i++) {
str + = Result.d[i];
$ (' #mydiv '). Text (str);
<div id= "mydiv" ></div>
<input id= "Button1" type= "button" value= "button"/>

Calling WebService via Ajax.NET

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: 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.