ajax请求ashx报错object XMLHttpRequest
function saveclick() {
var subject = $("#<%=subject.ClientID %>").attr("value");
var starttime = $("#<%=starttime.ClientID %>").attr("value");
var endtime = $("#<%=endtime.ClientID %>").attr("value");
var isallday = $("#<%=isallday.ClientID %>").attr("checked");
var warn = $("#<%=warn.ClientID %>").attr("checked");
var description = $("#<%=description.ClientID %>").val();
$.ajax({
type: "post",
// contentType: "application/json",
dataType: "json",
cache: false,
url: "MyLog.ashx?subject=" + subject + "&starttime=" + starttime + "&endtime=" + endtime + "&isallday=" + isallday + "&warn=" + warn + "&description=" + description,
success: function () {
alert("添加成功");
}
});
parent.$.ligerDialog.close();
parent.$(".l-dialog,.l-window-mask").remove();
}
<input id="Button2" type="button" value="确定" runat="server" class="button2" onclick="saveclick()"/>
public class MyLog : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string cnnstr = ConfigurationManager.ConnectionStrings["WorkDiaryConstr"].ConnectionString;
SqlConnection connection = new SqlConnection(cnnstr);
String insertcmd = "insert into WorkDiary(Work_UserID,Work_Title,Work_Description,Work_StartTime,Work_EndTime,Work_IsAllDayEvent,Work_WarnID,Work_Warn_State) values(newid(),@subject,@description,@starttime,@endtime,@isalldayevent,@warnid,@state)";
SqlCommand mycmd = new SqlCommand(insertcmd, connection);
mycmd.Parameters.AddWithValue("@subject", context.Request.Params["subject"].ToString());
mycmd.Parameters.AddWithValue("@description", context.Request.Params["description"].ToString());
&