0

I am having ASP.NET MVC application in which i have to send data from client browser to the server. Client browser means that data is present in javascript function (calculated) now what should i use to send this data to server . Before MVC, in my old application i was using Web Methods Please advice

batwadi
  • 1,836
  • 7
  • 29
  • 42
  • See this [question](http://stackoverflow.com/questions/560575/asp-net-mvc-how-to-pass-json-object-from-view-to-controller-as-parameter). – kgiannakakis Nov 19 '09 at 19:24

2 Answers2

1

you can use AJAX, e.g. in jQuery:

$.post(url, { name: "value"}, callback }

Shachar
  • 943
  • 1
  • 9
  • 18
1

Say you have a controller called HomeController and a actionResult called Index that loads up the index page and another actionResult called SaveData(string data)

Now in the index page you would write your script

$(function()
{
   var data = // get data.
   $.post('SaveData',{ sendingData: data}, function(response)
   {
          alert(response);
   });
});

public ActionResult SaveData(string sendingData)
{
   // do somethig with the data  
}

Thats all to it. No more making generic handlers or a webserver for each ajax request.

chobo2
  • 83,322
  • 195
  • 530
  • 832