Click here to Skip to main content
11,710,472 members (81,801 online)
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 10: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 Sergey Alexandrovich Kryukov 549
1 OriginalGriff 255
2 Peter Leow 174
3 Abhinav S 110
4 Suvendu Shekhar Giri 90
0 Abhinav S 60
1 Member 4653839 40
2 barneyman 35
3 Sergey Alexandrovich Kryukov 35
4 Member 11793820 35

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 21 Jun 2011
Copyright © CodeProject, 1999-2015
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