MVC 使用JQuery..jquery ajax Ajax

更新时间:15-06-30 04:35 热度:599
 

  
return Json(listP);

#endregion

listP.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Person>(s));

foreach (string s in listStr)

List<string> listStr = json.Split(‘,’).ToList<string>();

List<Person> listP = new List<Person>();

public JsonResult deSerializingList(string json)

return Json(ls);

Man = true

LastName = “JJ”,

FirstName = “Z”,

ID = 2,

ls.Add(new Person

Man = false

LastName = “HY”,

FirstName = “C”,

ID = 1,

ls.Add(new Person

List<Person> ls = new List<Person>();

public JsonResult serializingList()

#region================返回集合================

#endregion

return Content(Newtonsoft.Json.JsonConvert.SerializeObject(p));

Person p = Newtonsoft.Json.JsonConvert.DeserializeObject<Person>(json);

public ContentResult getJsonDeSerializingJson(string json)

/// <returns></returns>

/// <param name=”form”></param>

/// </summary>

/// $.getJSON听说反序列化json

/// <summary>

return Content(Newtonsoft.Json.JsonConvert.SerializeObject(p));

LastName = LastName

FirstName = FirstName,

ID = int.Parse(ID),

Person p = new Person

public ContentResult getJsonSerializingJson(string ID, string FirstName, string LastName)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”ID”></param>

/// </summary>

/// $.getJSON相比看jquery序列化Json

/// <summary>

return Json(p);

Person p = Newtonsoft.Json.JsonConvert.DeserializeObject<Person>(form["json"].ToString());

public JsonResult testDeSerializingJson(FormCollection form)

/// <returns></returns>

/// <param name=”form”></param>

/// </summary>

/// $.Ajax反序列化json

/// <summary>

return Content(Newtonsoft.Json.JsonConvert.SerializeObject(p));

LastName = form["LastName"]

FirstName = form["FirstName"],

ID = int.Parse(form["ID"]),

Person p = new Person

public ContentResult testSerializingJson(FormCollection form)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”ID”></param>

/// </summary>

/// $.Ajax听听asp序列化Json

/// <summary>

#region============Newtonsoft.Json.dll(json序列化和反序列化测试)=============

#endregion

return Content(“{‘id’:’3′}”);

public ContentResult getJson3(string ID, string FirstName, string LastName)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”Code”></param>

/// </summary>

/// 对于asp产生错误前台没反应

///经测试发现必须是双引号(”)不能是单引号(‘)

/// <summary>

return Content(“{\”id\”:\”2\”,\”name\”:\”chy\”}”);

public ContentResult getJson2(string ID, string FirstName, string LastName)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”Code”></param>

/// </summary>

/// 学习MVC经测试发现必须是双引号(”)不能是单引号(‘)

/// <summary>

return Content(“{\”id\”:1,\”name\”:\”chy\”,\”flag\”:true}”);

public ContentResult getJson1(string ID, string FirstName, string LastName)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”Code”></param>

/// </summary>

/// 我不知道jquery api经测试发现必须是双引号(”)不能是单引号(‘)

/// <summary>

#region ==============$.getJSON(返回json格式测试)============

#endregion

return Content(“({id:’2′,FirstName:’C',LastName:’HY’})”);

public ContentResult getJsonString()

/// <returns></returns>

/// </summary>

/// 学会jquery..jquery测试返回json字符串

/// <summary>

return Content(“{id:’2′,FirstName:’C',LastName:’HY’}”);

public ContentResult getString()

/// <returns></returns>

/// </summary>

/// jquery ui 中文手册测试返回字符串

/// <summary>

return Json(p);

LastName = LastName

FirstName = FirstName,

ID = int.Parse(ID),

Person p = new Person

public JsonResult getPerson2(string ID, string FirstName, string LastName)

/// <returns></returns>

/// <param name=”LastName”></param>

/// <param name=”FirstName”></param>

/// <param name=”ID”></param>

/// </summary>

/// 学习使用所以把Global中定义为{controller}/editpost/{uid}

/// 前台url?ID=3&FirstName=C&LastName=HY传到后台时ID值为”"

///经测试发现:当Global中定义{controller}/editpost/{id}时

/// <summary>

return Json(p);

LastName = form["LastName"]

FirstName = form["FirstName"],

ID = int.Parse(form["ID"]),

Person p = new Person

public JsonResult getPerson(FormCollection form)

/// <returns></returns>

/// <param name=”form”></param>

/// </summary>

/// 事实上asp测试返回对象

/// <summary>

#region ===============$.Ajax测试=================

public class AjaxTestController : Controller

public bool Man { get; set; }

public string LastName { get; set; }

public string FirstName { get; set; }

public int ID { get; set; }

public class Person

namespace MvcApplication.Controllers

using System.Web.Mvc;

using System.Web;

using System.Runtime.Serialization.Json;

using System.Linq;

using System.Collections.Generic;

using System;


Controllers 学习jquery ui 下载代码:

alert(“请求失败”);

error: function() {

alert(item + “:” + json[item]);

$.each(this, function(item, value) {

$.each(obj, function() {

alert(obj + “length:” + obj.length);

success: function(obj) {

cache: false,

async: true,

data: “”,

url: “/AjaxTest/serializingList”,

type: “POST”,

$.ajax({

$(“#ButSerializingList”).click(function() {

alert(“对比一下jquery ui 中文手册请求失败”);

error: function() {

alert(obj.ID + obj.FirstName + obj.LastName + obj.Man);

success: function(obj) {

cache: false,

async: true,

data: ‘json={“ID”:201,”FirstName”:”C”,”LastName”:”HY”,”Man”:true}’,

url: “/AjaxTest/testDeSerializingJson”,

type: “POST”,

$.ajax({

$(“#ButDeSerializing”).click(function() {

alert(“对于net请求失败”);

error: function() {

alert(obj);

success: function(obj) {

cache: false,

async: true,

data: “ID=101&FirstName=C&LastName=HY&Man=false”,

url: “/AjaxTest/testSerializingJson”,

type: “POST”,

$.ajax({

$(“#ButSerializing”).click(function() {

//==================================================net==============

alert(item + “:” + json[item]);

$.each(json, function(item, value) {

alert(json);

$.getJSON(“/AjaxTest/getJsonDeSerializingJson”, { json: ‘{“ID”:201,”FirstName”:”C”,”LastName”:”HY”,”Man”:true}’ }, function(json) {

$(“#ButJson5″).click(function() {

alert(item + “:” + json[item]);

$.each(json, function(item, value) {

alert(json);

$.getJSON(“/AjaxTest/getJsonSerializingJson”, { ID: “22″, FirstName: “C1″, LastName: “HY1″ }, function(json) {

$(“#ButJson4″).click(function() {

alert(item + “:” + json[item]);

$.each(json, function(item, value) {

alert(json);

$.getJSON(“/AjaxTest/getJson3″, { ID: “22″, FirstName: “C1″, LastName: “HY1″ }, function(json) {

$(“#ButJson3″).click(function() {

alert(item + “:” + json[item]);

$.each(json, function(item, value) {

alert(json);

$.getJSON(“/AjaxTest/getJson2″, { ID: “22″, FirstName: “C1″, LastName: “HY1″ }, function(json) {

$(“#ButJson2″).click(function() {

alert(item + “:” + json[item]);

$.each(json, function(item, value) {

alert(json);

$.getJSON(“/AjaxTest/getJson1″, { ID: “22″, FirstName: “C1″, LastName: “HY1″ }, function(json) {

$(“#ButJson1″).click(function() {

//================================================================

alert(“相比看jquery ui框架请求失败”);

error: function() {

alert(item + “:” + obj[item]);

$.each(obj, function(item, value) {

var obj = eval(str);

success: function(str) {

cache: false, //不加载缓存

async: true, //异步

url: “/AjaxTest/getJsonString”,

type: “POST”, //默认是GET

$.ajax({

$(“#ButAjax4″).click(function() {

alert(“请求失败”);

error: function() {

alert(str);

success: function(str) {

cache: false, //想知道jquery.js下载不加载缓存

async: true, //异步

url: “/AjaxTest/getString”,

type: “POST”, //默认是GET

$.ajax({

$(“#ButAjax3″).click(function() {

alert(“请求失败”);

error: function() {

alert(obj.ID + obj.FirstName + obj.LastName + obj.Man);

success: function(obj) {

cache: false, //想知道jquery ui不加载缓存

async: true, //异步

url: “/AjaxTest/getPerson2?ID=3&FirstName=C&LastName=HY”,

type: “POST”, //默认是GET

$.ajax({

$(“#ButAjax2″).click(function() {

alert(“请求失败”);

error: function() {

alert(obj.ID + obj.FirstName + obj.LastName + obj.Man);

success: function(obj) {

cache: false, //不加载缓存

async: true, //异步

data: “ID=1&FirstName=C&LastName=HY”,

url: “/AjaxTest/getPerson”,

type: “POST”, //对比一下mvc默认是GET

$.ajax({

$(“#ButAjax”).click(function() {

客户端调用方式:

使用到:Jquery.js 以及 Newtonsoft.Json.dll

想知道Ajax想知道jquery mobile 下载
我不知道jquery
学习jquery插件下载
ajax
jquery
MVC
ajax
net
jquery下载文件
学会Ajax
学习使用JQuery
学jquery mobile习jquery1.9下载
对于jquery ui 教程
ajax
相比看jquery api 中文下载
相比看ajax
事实上
相比看jquery手册下载
看想知道使用JQuery看jquery