2013-06-28 57 views
-5
$("[id$=_btnPostReminder]").click(function(){ 
    var a = $find("<%=Editor1.ClientID%>"); 
    var remindertext = a.get_content(); 
    var re=$("#<%=hiddReminderTicketId.ClientID%>").text(); 
    var res= $("#<%=txtReminderon.ClientID%>").val(); 
    $.ajax({ 
     type: "POST", 
     url: "AllTickets.aspx/btnPostReminder", 
     data: '{TicketId: ' + re + ',remindertext: ' + remindertext + ',reminderon: ' + res + '}', 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: 
     function Ret(response) { 
     var Result=response.d 
     alert(Result) 
     $("#<%=txtReminderon.ClientID%>").val("") 
     $('#<%=hiddReminderTicketId.ClientID %>').text("") 
     $('#<%=lblAlert.ClientID %>').text("Set Successfully"); 
     return false; 
     }, 
     error: function(data, status, jqXHR) {       
     alert(jqXHR); 
     } 
    }); 
    return false; 
}); 

C#代碼隱藏:jQuery的AJAX POST方法給內部服務器錯誤

[System.Web.Services.WebMethod()] 
public static string btnPostReminder(Int64 TicketId, string remindertext, string reminderon) 
{ 
    Common objCommon = new Common(); 
    DAL objDal = new DAL(); 
    SqlParameter[] para = new SqlParameter[4]; 
    para[0] = new SqlParameter("@ticketid", DbType.Int64); 
    para[0].Value = TicketId; 
    para[1] = new SqlParameter("@REMINDERTEXT", DbType.String); 
    para[1].Value = remindertext; 
    para[2] = new SqlParameter("@REMINDERON", DbType.DateTime); 
    para[2].Value = objCommon.ReturnDate(reminderon); 
    para[3] = new SqlParameter("@CREATEDBY", DbType.Int64); 
    para[3].Value = Convert.ToInt64(1); 

    objDal.ExecuteSP("CREATE_REMINDER", para); 

    return " successfully"; 
} 
+0

這裏提供的信息不夠充分。 –

+0

顯示確切的錯誤。 – Zaki

+0

感謝您的回覆,當我點擊按鈕時,應該調用ajax post方法,但執行警告方法後顯示內部服務器錯誤 –

回答

1

好找到你的問題,你是路過Int64爲參數,改成下面我獲得成功時,這應該是字符串,否則如此消息:

[System.Web.Services.WebMethod()] 
public static string btnPostReminder(string TicketId, string remindertext, string reminderon) 
    { 
     return " successfully"; 
    } 

而且你的數據應該如下:

data: '{"TicketId":"' + re + '","remindertext":"' + remindertext + '","reminderon":"' + res + '"}', 

作爲字符串傳遞給參數,並傳遞給TryParse以查看它是否是int類型。

+0

其工作非常非常感謝所有... –

相關問題