JSON数据表传球失败 [英] Json Data table passing failed
问题描述
我的AJAX不工作,但我的JSON结果是回归行数12,它不显示任何警报消息。我在浏览器中查看,它显示了500内部服务器错误。
如果检查目的,我给定的字符串值工作表数据不工作有获取任何其他方法的数据表
我的JSON结果
公众的ActionResult GroupFix(字符串ID,字符串名称)
{
清单< Tbltable> FIX =新的List< Tbltable>();
FIX = entity.Tbltable.Where(X => x.Name ==名和放大器;&安培; x.id == ID).ToList();
返回JSON(修复,JsonRequestBehavior.AllowGet);
}
我的jQuery
$后(/首页/ GroupFix。{名称:姓名,身份证:身份证},功能(结果){
警报('海');
$。每个(结果,功能(值,键){
警报('名');
$('#fixtab TBODY')追加(。'< TR>< TD>'+ value.name +'< / TD>< TD>'+ value.id +'< / TD>< / TR>');
});
}JSON);
好了没有得到确切的问题,但请参阅下面的code这工作,因为我想在我的情况...
jQuery的
$。阿贾克斯({
键入:POST,
网址:URL,
数据:贾森数据
的contentType:应用/ JSON的;字符集= UTF-8,
数据类型:JSON
成功:函数(MSG){
VAR T = window.JSON.parse(msg.d);
//你的code。
}
});
C#code
[的WebMethod]
公共静态字符串的SendMessage()
{
// code
//返回新的JavaScriptSerializer()序列化()。
}
确认杰森关键数据类型和它的名字一样的方法称为BA参数参数名称...
My AJAX is not working but my JSON result is return row count is 12 and it is not showing any alert messages. I check in browser, it shows 500 internal server error.
If checking purpose I given string value is working for data table is not working there is any other method for getting data table
My JSON Result
public ActionResult GroupFix(string id, string name)
{
List<Tbltable> Fix = new List<Tbltable>();
Fix = entity.Tbltable.Where(x => x.Name == name && x.id == id).ToList();
return Json(Fix, JsonRequestBehavior.AllowGet);
}
My jQuery
$.post("/Home/GroupFix", { name: Name, id : id }, function (result) {
alert('hai');
$.each(result, function (value, key) {
alert('name');
$('#fixtab tbody').append('<tr> <td>' + value.name + '</td> <td>' + value.id + '</td> </tr>');
});
}, "json");
Well not get exact problem, but see below code which work as I wish in my case...
Jquery
$.ajax({
type: "POST",
url: "url",
data: "jason-data",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var t = window.JSON.parse(msg.d);
// Your code.
}
});
c# code
[WebMethod]
public static string SendMessage()
{
// Code
// return new JavaScriptSerializer().Serialize();
}
Make sure jason key datatype and it's name same as the argument name of method called ba parameters....
这篇关于JSON数据表传球失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!