jQuery Ajax请求收到<!DOCTYPE html> [英] JQuery Ajax request recieves <!DOCTYPE html>
问题描述
我要向同一文档发送日期,并且一切正常,直到我想将响应值与字符串进行比较.这是我的JQuery:
I am sending a piece of date to the same document and everything works fine until I want to compare the response value with a string. So here is my JQuery:
$.ajax({
type: 'POST',
dataType : 'html',
cache: false,
data: {serienummer: serial},
success: function(response) {
console.log(response);
if ('success' == response){
//Do something
} else {
//Do something else
}
},
error: function(xhr, status, error){
alert('error: ' + error);
}
});
我将数据发布到同一页上,并将其与数据库中的数据进行比较,如果存在比较,则返回成功",如果没有比较,则返回错误".
I post the data to the same page and compare it with the data in my database and return "success" if there is a comparision or return "error" if there is not.
但是,如果我使用console.log()响应,则会得到以下信息:
But if I console.log() the response I get the following:
success<!DOCTYPE html>
为什么这不仅是成功"还是错误"?如何解决此问题以比较响应?与dataType有关吗?
Why is this not just 'success' or 'error'? How can I solve this to compare the response? Has it something to do with the dataType?
预先感谢
推荐答案
exit();在处理所有内容的PHP代码的末尾完成了工作!我希望这对某人有帮助
exit(); at the end of the PHP code that processes everything did the job! I hope this helps someone
这篇关于jQuery Ajax请求收到<!DOCTYPE html>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!