Ahm*_*mad -1 html javascript asp.net ajax jquery
我有一个Web应用程序,它有许多按钮调用代码隐藏页面来执行SQL中的某些功能,然后向用户返回一条消息.
所有按钮都按预期工作.除了我要描述的那个.请注意,我已从其他按钮点击事件中复制了相同的javascript代码.
以下是单击按钮时发生的情况:
a)click触发事件.
b)$.ajax()函数正常工作之前的任何代码
c)调用函数后面的代码,并按预期工作
d)来自代码的返回值很好.
e)$.ajax()未触发成功/错误功能.
为什么??我在这里做错了什么?
我有以下HTML:
<div class='button approve' req_id='123' user_id='ahmad' reason='something'>
Approve
</div>
Run Code Online (Sandbox Code Playgroud)
以下javascript:
$(document).on('click', '.button.approve', function () {
var req_id = $(this).attr('req_id');
var reason = $(this).attr('reason');
var user_id = $(this).attr('reason');
alert('Before ajax'); //this is triggered normally.
$.ajax({
type: "POST",
url: "getData.aspx/approve",
data: "{req_id:'" + req_id + "', reason:'" + reason + "',user_id:'" + user_id + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
succss: function (data) {
alert('success'); //this never gets called
},
error: function (a, b, c) {
alert('error'); //this never gets called
}
});
});
Run Code Online (Sandbox Code Playgroud)
以及后面的ASPX代码:
<WebMethod()> Public Shared Function approve(ByVal req_id As String, ByVal user_id As String, ByVal reason As String) As String
Dim reply As String = "-received data is " & req_id & user_id & reason
Return reply 'in debug mode, the value of reply as valid
End Function
Run Code Online (Sandbox Code Playgroud)