Home > Net >  To communicate with asp.net ajax
To communicate with asp.net ajax

Time:10-19

<% @ WebService Language="#" Class="QuotationService % & gt;"
Using System;
Using System. The Web;
Using System. Web. Services;
Using System. Web. Services. Separate Protocols;
Using System. Web. Script. Services;
Using System. Collections. Generic;
[WebService (Namespace="http://tempuri.org/")]
[WebServiceBinding (ConformsTo=WsiProfiles. BasicProfile1_1)]
[ScriptService]
Public class QuotationService: System. Web. Services. WebService
{
[the WebMethod]
Public string GetQuote ()
{
List Quotes=new List (a);
Quotes. The Add (" The fool who is silent passes for wise. ");
Quotes. The Add (" The early bird catches The worm. ");
Quotes. The Add (" If wishes were true, shepherds whenever Kings. ");
The Random RND=new Random ();
Return quotes [RND. Next (quotes. Count)];
}
}

PTG
Calling Web Services from the Client 1779
40
})
});
});
</script>

<body>








CodePudding user response:

<% % @ Page Language="c #" & gt;
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & gt;
Show Web Service Method
The $(document). Ready (function () {
$(" # btnGet "). Click (function () {
$. Ajax ({
Type: "POST",
DataType: "json",
ContentType: "application/json,"
Url: "QuotationService asmx/GetQuote",
Success: the function (data) {
$(" # spanQuote "). The HTML (data. D);
},
Error: function () {
Alert (" The call to The web service failed. ");
}
CHAPTER 40 Client - Side AJAX with jQuery
From the Library of Wow! eBook

CodePudding user response:

Can not Restful access?
I don't feel I can directly through the ajax call web services,

CodePudding user response:

Can be accessed,
Just use it is not recommended, however,
https://blog.csdn.net/lovecruel/article/details/6697764

CodePudding user response:

By default only supports SOAP webservice
If you want to support the GET/POST
https://blog.csdn.net/weixin_34143774/article/details/89750606

CodePudding user response:

No webservice

Only need in aspx. Cs page used within
[the WebMethod] tag to a public static method can

https://www.cnblogs.com/sxhlf/p/6709264.html
  • Related