views:

64

answers:

3

Hi all,

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

A: 

See this question.

kgiannakakis
A: 

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

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

Shachar
+1  A: 

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