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

"博主在网站上实现Ajax请求时遇到一个问题,尽管请求返回状态为200OK,jQuery却执行了错误事件。代码显示在`Jqueryoperation.aspx`页面中,尝试删除记录后,期望收到`("Recorddeleted")`字符串提示,但并未接收到。问题可能出在响应处理或回调函数配置上。寻求解决方案。"
摘要由CSDN通过智能技术生成

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

I have implemented an Ajax request on my website, and I am calling the endpoint from a webpage. It always returns **200 OK**, but jQuery executes the error event. I tried a lot of things, but I could not figure out the problem. I am adding my code below:

### jQuery代码

### jQuery Code

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);

}

### `JqueryOpeartion.aspx`

的C#代码

### C# code for `JqueryOpeartion.aspx`

protected void Page_Load(object sender, EventArgs e) {

test();

}

private void test() {

Response.Write("《script language='javascript'》alert('Record Deleted');《/script》");

}

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

I need the `("Record deleted")` string after successful deletion. I am able to delete the content, but I am not getting this message. Is this correct or am I doing anything wrong? What is the correct way to solve this issue?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值