MVC 使用JQuery.Aj jquery ajax ax

更新时间:15-06-30 04:36 热度:503
 

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

基于 XML 和 JSON 数据源的自动输入建议工具

#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>

/// $.getJSONjquery插件反序列化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>

/// $.getJSONasp序列化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想知道asp反序列化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看着MVC序列化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>

/// 学习mvc产生错误前台没反应

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

/// <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>

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

/// <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 mobile经测试发现必须是双引号(”)不能是单引号(‘)

/// <summary>

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

#endregion

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

public ContentResult getJsonString()

/// <returns></returns>

/// </summary>

/// 听说jquery测试返回json字符串

/// <summary>

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

public ContentResult getString()

/// <returns></returns>

/// </summary>

/// 想知道使用JQuery测试返回字符串

/// <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>

/// 看看jquery.aj所以把Global中定义为{controller}/editpost/{uid}

/// 前台url?ID=3&FirstName=C&LastName=HYaj传到后台时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>

/// 想知道ajax测试返回对象

/// <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手册下载代码:

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(“听听net请求失败”);

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(“asp请求失败”);

error: function() {

alert(obj);

success: function(obMVCj) {

cache: false,

async: true,

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

url: “/AjaxTest/testSerializingJson”,

type: “POST”,

$.aj其实jqueryax({

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

//===========jquery easyui=====================================================

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(“我不知道ax请求失败”);

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”, //学习jquery默认是GET

$.ajax({

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

alert(“请求失败”);

error: function() {

alert(str);

success: function(str) {

cache: false, //看看jquery api不加载缓存

async: true, //异步

/// <returns></returns>

/// </summary>

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

对比一下jquery easyui学会jquery mobile 下载
你看ajax
net
你知道使用JQuery
事实上net
使用
事实上jquery插件下载
jquery easyui
jquery ui 教程
事实上Aj
jquery ui 中文手册
jquery看看jquery ui dialog ui
jquery插件下载
你看jquery ui 下载
ax
你知道jquery
听说ax
事实上ajax