How to send and receive data using ASP.NET Web Service and JQuery?
I want to run a web service method with parameters and get method return value back using JQuery.
ie.
client :
var result = dosomething(var p1, var p2, var p3 ....);
开发者_开发百科
when do something accesses WebService with
dosomewebservice(int p1,int p2, string p3) { return "something" };
result == "something";
You can access with jQuery a web service marked with attribute [ScriptService]
.
Example
First of all, does your web service call need to be asynchronous? And do you want to return XML or JSON.
If you're returning a string, use JSON - much faster over the wire. Even though your serializing/deserializing (which causes overhead), the overhead on the server/client is better than the overhead over the wire.
Calling a JSON-web service using jQuery - look at $.getJSON.
精彩评论