[英]How to append data table in html table using json?
I need to show all table fixture layout in html table using ajax method but it doesn't working i dont know the problem please some one help me friends and my code. 我需要使用ajax方法在html表中显示所有表夹具布局,但它不起作用我不知道问题请一些人帮我朋友和我的代码。 .
。 .
。
Controller JsonResult 控制器JsonResult
public JsonResult FixturesVal(string TournamentName, string GroupName, string MatchDate, string MatchType, string GroundName, string MatchName, string TeamA, string TeamB, string Schedule)
{
string League = "";
DateTime MatchPlayedOn = DateTime.ParseExact(MatchDate, "dd-MM-yyyy", CultureInfo.CurrentCulture);
if (MatchType == "League")
{
League = objdetails.LeagueValidation(TournamentName, GroupName, MatchPlayedOn, MatchType, GroundName, TeamA, TeamB,Schedule);
}
if (League == "OK")
{
objdetails.AddFixture(TournamentName, GroupName, MatchType, MatchPlayedOn, Schedule, GroundName, MatchName, TeamA, TeamB,"New Tournament");
League = objdetails.Save();
}
//var FixtureLayout = objdetails.TeamsForFixtures(TournamentName);
int value = objdetails.Number(TournamentName, GroupName);
var data = new { League, value };
return Json(data, JsonRequestBehavior.AllowGet);
}
My Jquery 我的Jquery
$.post("/Fixtures/FixturesVal", { TournamentName: TournamentName, GroupName: GroupName, MatchDate: date, MatchType: MatchType, GroundName: ground, MatchName: $('#MatchCount').val(), TeamA: TeamA, TeamB: TeamB, Schedule: sche }, function (result) {
$('#MatchCount').val("M" + result.value);
$.each(result.FixtureLayout, function (i, value) {
tbody += '<tr><td>' + value.GroupName + '</td><td>' + value.MatchDate + '</td></tr>';
});
alert(tbody);
},"json");
This functions are not working 此功能无效
Regarding general error detection in javascript : 关于javascript中的一般错误检测:
Fire up your browser console and check for errors. 启动浏览器控制台并检查错误。
You may want to add a .fail
callback to your $.post()
call : 您可能想要在
$.post()
调用中添加.fail
回调:
$.post(...).fail(function(){ console.log('error', arguments); });
to see if your request fails. 查看您的请求是否失败。
Regarding your specific problem : 关于你的具体问题:
Try specifying the dataType
parameter in your $.post()
call : 尝试在
$.post()
调用中指定dataType
参数:
$.post(url, {...}, function(result){...}, "json")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.