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.
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.
http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With