asp.net MVC3和jQuery AJAX教程 [英] asp.net MVC3 and jquery AJAX tutorial

查看:152
本文介绍了asp.net MVC3和jQuery AJAX教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个非常详细的电子书/教程/在非常简单的语言jQuery的AJAX和JSON asp.net MVC3视频。我一直在使用Google,但便无法找到任何好的。请给我联系。

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.

感谢。

推荐答案

从客户端使用 $就

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

从服务器端处理Ajax请求:

From a server side handle ajax requests:

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

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

使用 JsonResult 以JSON字符串返回到客户端和< A HREF =htt​​p://www.json.org/js.html> JSON.parse 在客户端解析JSON字符串。

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

要简化Ajax调用也可以围绕创建包装$就和JsonResult,定义诸如 {数据:jsonString,messagess:[],REDIRECT_URL}您的Ajax请求结构等。

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.

这就是所有的教程。

这篇关于asp.net MVC3和jQuery AJAX教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆