我試圖調用我的.aspx文件中的方法來調用另一個.aspx文件。我使用的文件是另一個文件夾裏面,文件,我需要使用JavaScript來訪問超出類似這樣的結構:Ajax請求無法訪問.aspx文件上的方法
Root Folder:
PageMethods.aspx
SubFolder/
Somefile.aspx
這裏是我的Ajax請求:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/PageMethods.aspx/TagtoVehicle",
data: "{'colIDBigint': '" + IDBigInt + "', 'colTravelReqIDInt': " + TravelReq +
", 'colRecordLocatorVarchar': " + RecordLoc + ", 'colSeafarerIdInt': " + SeafarerId + ", 'colOnOff': " + onoff + ", 'colPortAgentVendorIDInt': " + Vehiclevendor + ", 'UserId': " + userId + "}",
dataType: "json",
success: function(data) {
} ,
error: function(objXMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
當我運行ajax請求會引發錯誤500(內部服務器錯誤)。
爲什麼要求不會通,即使我的PageMethod.aspx.cs裏面是這樣的:
[WebMethod]
public static string TagtoVehicle(Int32 colIDBigint, Int32 colTravelReqIDInt, string colRecordLocatorVarchar, Int32 colSeafarerIdInt, string colOnOff, Int32 colPortAgentVendorIDInt,string UserId)
{
}
是什麼觸發了錯誤500?
我只是試過了,它會拋出同樣的錯誤。 – marchemike 2014-09-04 06:34:33