Click here to Skip to main content
12,077,147 members (47,708 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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
 
good
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[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hi,
You can achive this by Jquery ajax. Lets say you have a web method Report1 that takes 2 parameter fromDate and toDate.

[WebMethod]
public static String Report1(String fromDate,String toDate)
{
  //function body
}

now you can call the above method by jquery ajax
$.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
  Permalink  
Comments
Monjurul Habib 21-Jun-11 17:37pm
   
5++,nice detail with link..proposed as answer.
Rate this: bad
 
good
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.

http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/[^]

http://vincenthomedev.wordpress.com/2009/02/10/consuming-an-aspnet-web-service-or-page-method-using-jquery/[^]
  Permalink  
Comments
Shahriar Iqbal Chowdhury 21-Jun-11 16:44pm
   
nice
Monjurul Habib 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 21 Jun 2011
Copyright © CodeProject, 1999-2016
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