【发布时间】:2018-06-21 08:37:49
【问题描述】:
我正在尝试将对象发布到 json 服务器,但出现 500 内部服务器错误。在此代码中,在 localHost 中工作正常,但无法正常工作,我的代码中有任何错误
$.ajax({
type: 'POST',
url: '/Booking/CheckAvailability',
dataType: 'json',
cache: false,
data: {
LocationID: locationID,
VenueID: venueID,
FacilityID: facilityID,
BookedFromDate: bookedFromDate,
BookedToDate: bookedToDate,
FromTime: fromtime,
ToTime: Ttime
},
traditional: true,
success: function (data) {
if (data.success) {
$("#VenueBooking").show();
}
if (data.False) {
alert("Aleardy Booked");
}
},
error: function (ex) {
alert('Failed to retrieve Sub Categories : ' + ex);
}
});
代码:
[HttpPost]
public ActionResult CheckAvailability(int locationID, int venueID, int facilityID, string bookedFromDate, string bookedToDate, string fromTime, string toTime)
{
try
{
Get_Location();
if (ModelState.IsValid)
{
locationInformation check = new locationInformation();
bool suc = check.CheckAvailability(bookedFromDate, bookedToDate, fromTime, toTime);
if (suc == false)
{
return Json(new { success = true, message = "Checked successfully" }, JsonRequestBehavior.AllowGet);
}
else if (suc == true)
{
return Json(new { False = true, message = "Checked successfully" }, JsonRequestBehavior.AllowGet);
}
}
return View();
}
catch
{
return View();
}
}
【问题讨论】:
-
@RoryMcCrossan 更新
-
你没有日志?
-
您需要单步执行您的 c# 代码以查看导致内部错误的原因
-
@Pete 正在制作中。
-
恐怕,如果日志不能帮助你,我们怎么能?
标签: javascript jquery ajax asp.net-mvc