【发布时间】:2021-02-14 06:09:00
【问题描述】:
我正在使用 jQuery 将表单字段发布到 PHP 文件,该文件仅返回 1/0,具体取决于它是否有效...
代码摘录:
$.ajax({
url: "ajax/save_text.php", //Relative?!?
//PHP Script
type: "POST",
//Use post
data: 'test=' + $(this).val(),
datatype: 'text',
//Pass value
cache: false,
//Do not cache the page
success: function(html) {
if (html == 1) {
$(this).hide().siblings('span').html($(this).value).show();
alert("awesome!");
} else alert('It didn\'t work!');
},
//Error
error: function() {
alert("Another type of error");
}
});
但是每次成功(html == 1)控制台都会抛出错误
未捕获的类型错误:无法读取未定义的属性“defaultView”
警报永远不会发生...?
Google 似乎没有太多关于这个错误和 jQuery 的信息,谁知道原因?
【问题讨论】: