Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Javascript C#4.0 C#3.5 , +
Hello Friends i have start learning JSON.
I create a WEB SERVICE(asmx) in ASP.NET i used JSON in it.
I want to call webmethods with jQuery, JavaScript or Ajax.
Now i want to call my Method taking 2 or more parameter.

so i don't know how to use this i m beginner of Ajax,jQuery.
Posted 21-Jun-11 11:15am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Take a look at this, perfect fit for what you are asking for.
How to call a Web Service from client-side JavaScript using ASP.NET AJAX[^]
Also, you can refer to Client-Side Web Service Calls with AJAX Extensions[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You can achive this by Jquery ajax. Lets say you have a web method Report1 that takes 2 parameter fromDate and toDate.
public static String Report1(String fromDate,String toDate)
  //function body
now you can call the above method by jquery ajax
 type: "POST",
 url: "default.aspx/Report1",
 data: "{fromDate:'1/1/2011',toDate:'6/30/2011'}"
 contentType: "application/json; charset=utf-8",
 dataType: "json",
 beforeSend: function () { $("#wait").show(); },
 complete: function () { $("#wait").hide(); },
 success: function (msg) {
	//msg.d contains the returned JSON
 error: function () { }
check here[^] for code samples
Monjurul Habib at 21-Jun-11 17:37pm
5++,nice detail with link..proposed as answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.getJSON() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise.
Please follow the link, hope it will help you.[^][^]
Shahriar Iqbal Chowdhury at 21-Jun-11 16:44pm
Monjurul Habib at 21-Jun-11 17:36pm
thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190

Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 21 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100