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
Asked
Active
Viewed 415 times
0
-
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 Answers
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