相关疑难解决方法(0)

Ajax请求返回200 OK,但是触发了错误事件而不是成功

我在我的网站上实现了一个Ajax请求,我从一个网页调用端点.它总是返回200 OK,但jQuery执行错误事件.我尝试了很多东西,但我无法弄清楚问题.我在下面添加我的代码:

jQuery代码

var row = "1";
var json = "{'TwitterId':'" + row + "'}";
$.ajax({
    type: 'POST',
    url: 'Jqueryoperation.aspx?Operation=DeleteRow',
    contentType: 'application/json; charset=utf-8',
    data: json,
    dataType: 'json',
    cache: false,
    success: AjaxSucceeded,
    error: AjaxFailed
});
function AjaxSucceeded(result) {
    alert("hello");
    alert(result.d);
}
function AjaxFailed(result) {
    alert("hello1");
    alert(result.status + ' ' + result.statusText);
}
Run Code Online (Sandbox Code Playgroud)

C#代码 JqueryOpeartion.aspx

protected void Page_Load(object sender, EventArgs e) {
    test();
}
private void test() {
    Response.Write("<script language='javascript'>alert('Record Deleted');</script>");
}
Run Code Online (Sandbox Code Playgroud)

("Record deleted")成功删除后我需要字符串.我可以删除内容,但我没有收到此消息.这是正确的还是我做错了什么?解决这个问题的正确方法是什么?

javascript asp.net ajax jquery json

754
推荐指数
9
解决办法
34万
查看次数

标签 统计

ajax ×1

asp.net ×1

javascript ×1

jquery ×1

json ×1