Javascript Jquery Ajax始终会触发错误
我不明白为什么我的自定义回调错误函数总是被触发。 如果删除此回调函数,则会触发成功回调函数 我在网上看到这是一个编码问题,但就我而言,我不这么认为 这是我的代码: 客户Javascript Jquery Ajax始终会触发错误,javascript,jquery,ajax,Javascript,Jquery,Ajax,我不明白为什么我的自定义回调错误函数总是被触发。 如果删除此回调函数,则会触发成功回调函数 我在网上看到这是一个编码问题,但就我而言,我不这么认为 这是我的代码: 客户 myFunction = function () { $.ajax({ url: customUrl, type: "POST", data: JSON.stringify(buildDatata("custom")), contentType: "app
myFunction = function () {
$.ajax({
url: customUrl,
type: "POST",
data: JSON.stringify(buildDatata("custom")),
contentType: "application/json",
dataType: "json",
success: mysuccess,
error: myerror("Error")
});
}
buildDatata= function (action) {
return data = {
"Action": action,
"SubscriptionInfo":
{
"SiteId": CurrentSiteId,
"WebId": CurrentWebId,
"ListId": CurrentListId,
"ItemId": CurrentItemUniqueId,
"SubscriptionDate": new Date().toUTCString(),
"SubscriptionType": GetTypePage()
}
}
}
在我的服务器中:
private void HasSubscripted(HttpContext context, BookmarkAction bookmarkAction)
{
bool result = true;
SendResponse(context,
new
{
isSubscripted = result
}
);
}
protected void SendResponse(HttpContext context, object jsonResponse)
{
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
context.Response.Clear();
context.Response.ContentType = "application/json";
context.Response.Write(jsonSerializer.Serialize(jsonResponse));
context.Response.End();
}
我做错了什么?我的错误(“错误”)。这是你真正的称呼。您不需要传入参数<代码>函数名()实际调用它。只需传递
myError
您正在调用一个函数。。。。它返回的内容被分配给事件侦听器非常感谢,我是dub:)非常感谢,我是dub:)dub是什么意思?点击错误,想说“哑巴”