Send JSON to webmethod?

Hannoun Yassir picture Hannoun Yassir · Oct 6, 2009 · Viewed 17.5k times · Source

How can i send a JSON object to a webmethod using jQuery?

Answer

TheVillageIdiot picture TheVillageIdiot · Oct 6, 2009

Please refer to this article by Dave Ward. It is a complete tutorial on doing this stuff. Also you will find there other great jquery/ASP.net stuff.

EDIT:- Dave is calling method without any arguments, you can replace empty data property with actual data you want to send:

$.ajax({
  type: "POST",
  url: "Default.aspx/GetDate",
  data: "{'name':'tiger1','hobbies':['reading','music']}",//PUT DATA HERE
  contentType: "application/json; charset=utf-8",
  dataType: "json",