我已经在我的网站上实现了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?