我正在调用WebMethod
函数,我在availability.aspx文件中对其进行了编码,我从javascript函数调用它webmethod
Webservice
在localhost网站上运行完美但在实时版本中,我在浏览器的控制台中收到了此错误。
POST http:// * / * ** / availability.aspx / addEvent 404(Not Found)
有什么区别,为什么不在现场工作?
availability.aspx
使用方法
的类定义using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web.Services;
public partial class driver_login_availability : System.Web.UI.Page
{
[WebMethod]
public static int addEvent(ImproperAvailability improperEvent)
{
availability cevent = new availability();
cevent.driverid = improperEvent.driverid;
cevent.name = improperEvent.name;
cevent.startdate = DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
cevent.enddate = DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
if (CheckAlphaNumeric(cevent.name))
{
int key = EventDAO.addEvent(cevent);
List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];
if (idList != null)
{
idList.Add(key);
}
return key;//return the primary key of the added cevent object
}
return -1;//return a negative number just to signify nothing has been added
}
}
和javascript:
$(document).ready(function () {
//add dialog
$('#addDialog').dialog({
autoOpen: false,
theme: false,
width: 470,
buttons: {
"Add": function () {
//alert("sent:" + addStartDate.format("dd-MM-yyyy hh:mm:ss tt") + "==" + addStartDate.toLocaleString());
var eventToAdd = {
driverid: $("#ctl00_ContentPlaceHolder1_addProjectID").val(),
name: "Available",
start: addStartDate.format("dd-MM-yyyy hh:mm:ss tt"),
end: addEndDate.format("dd-MM-yyyy hh:mm:ss tt")
};
if (checkForSpecialChars(eventToAdd.name)) {
alert("please enter characters: A to Z, a to z, 0 to 9, spaces. remove any dashes or commas or apostrophes. thanks!");
}
else {
//alert("sending " + eventToAdd.title);
PageMethods.addEvent(eventToAdd, addSuccess, addFailure, "User Context");
$(this).dialog("close");
}
}
}
});