Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net MVC3 and jquery AJAX tutorial [closed]

I need a very detailed ebook/tutorial/video in very simple language for jquery AJAX and JSON with asp.net MVC3 . I have been googling but could't find any good one. Please send me links.

Thanks.

like image 647
DotnetSparrow Avatar asked Jul 11 '11 19:07

DotnetSparrow


2 Answers

From a client side use $.ajax:

$.ajax({
   type: "POST",
   url: "users/save",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }

From a server side handle ajax requests:

public ActionResult Save(string name, string location)
{
  //Save data

  return new JsonResult(){Data = "User was saved!"};
}

Use JsonResult to return json string to the client and JSON.parse to parse json string at the client side.

To simplify ajax calls you can also create wrappers around $.ajax and JsonResult, define your ajax requests structure like {data:"jsonString", messagess: [], redirect_url } etc.

That's all tutorial.

like image 125
Andrew Orsich Avatar answered Sep 28 '22 05:09

Andrew Orsich


http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx

like image 29
Feferes.net Avatar answered Sep 28 '22 03:09

Feferes.net