开发者

asp.net MVC3 and jquery AJAX tutorial [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, 开发者_运维百科but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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


You could try one of the sessions from the MVCConf presented by Eric Sowell (@Mallioch). It is a good tutorial and so are quite a number.


Eric Sowell was mentioned above.

The link to his talk is:

Evolving Practices in Using jQuery and Ajax in ASP.NET MVC Applications

You need to understand JavaScript prototypes to understand, or rather, be able to use the recommended practice.

But it is well worth it. You end up with a VERY reusable pattern for ALL the javascript in your apps, not just the AJAX bits.

Plus you have something to bang your head against until you really understand JavaScript, as opposed to Cookbook recipes for jQuery.

Ie, if you don't structure your jQuery/JS in some way, you will end up with a bowl of spaghetti.

Other books: David Crockford wrote a short book: Javascript, the Good Parts. This explains prototypes and a lot else, very concisely. There is also a GREAT article in MSDN Magazine, May 2007 by Ray Djajadinata:

JavaScript: Create Advanced Web Applications with Object-Oriented Techniques

If you read that article ten times, you will understand JavaScript.


Did you try the official Microsoft resources?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜