![](/img/trans.png)
[英]ASP.NET MVC 500 (Internal Server Error) with ajax post method
[英]POST 500 (Internal Server Error) asp.net mvc
我正在嘗試將對象發布到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();
}
}
如果您無法調試服務器,我將嘗試查看瀏覽器開發人員工具中的“網絡”選項卡。 希望您能了解為什么會引發錯誤。 選擇失敗的請求,然后查看響應。
嘗試確保已添加CheckAvailabilty視圖。 請參閱下面的答案:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.