我遇到了一个问题,我总是从jquery的ajax调用中找回错误。它只发生在index.php程序中。我试图简化问题:这是从index.php中的代码:返回数据时返回AJAX错误
<script type="text/javascript">
function createSympathyData() {
$.ajax({
url: "buildsympathydata.php",
type: 'post',
success: function (jqxhr, status, errorMsg){
console.log(jqxhr, status, errorMsg);
$('#sympathy_target').append(jqxhr);
},
error: function(jqxhr, status, errorMsg) {
console.log(jqxhr, status, errorMsg);
},
})
};
$(document).ready(function(){
$('#sympathy_target').each(function() {
createSympathyData();
});
});
</script>
PHP程序 - buildsympathydata.php:
<?php
$buildhtml = 'test data';
echo $buildhtml; ?>
始终用警报(jqxhr)= [对象的对象返回错误],警报(状态)=错误,警报(errorMsg)=空白警报。使用jquery 1.6.1。在其他地方使用jquery和ajax没有任何问题。这些错误出现在我的本地主机和我的实时网站(FTP程序,测试,然后恢复原来的)。任何想法将不胜感激,因为我一直在试图解决这个问题几天。谢谢,丹尼
请不要滥用'警报()'这样。将调试记录在控制台中。 D: –
和状态? '警报(状态);' – zzlalani
错误块,而添加这个'的console.log(jqxhr,状态,ERRORMSG);' – zzlalani