Php 关于永久性错误的AJAX函数

Php 关于永久性错误的AJAX函数,php,jquery,ajax,Php,Jquery,Ajax,这个AJAX函数有问题,但我看不出有什么问题 阿贾克斯 $('.review')。单击(函数(){ var idatas=$(this.attr('rel'); 变量idata='idata='+idatas; $.ajax({ 键入:“POST”, url:“?审查”, 资料来源:idata, beforeSend:function(){ $(this.addClass('ractive'); }, 数据类型:'json', 成功:功能(数据){ $('#dbody').html(data.i

这个AJAX函数有问题,但我看不出有什么问题

阿贾克斯

$('.review')。单击(函数(){
var idatas=$(this.attr('rel');
变量idata='idata='+idatas;
$.ajax({
键入:“POST”,
url:“?审查”,
资料来源:idata,
beforeSend:function(){
$(this.addClass('ractive');
},
数据类型:'json',
成功:功能(数据){
$('#dbody').html(data.ioutput);
$('.cright').height($('.drop').height());
$('#dropout').addClass('dropopen');
},
错误:函数(数据){
$('#dbody').html('arse bitchy');
$('.cright').height($('.drop').height());
$('#dropout').addClass('dropopen');
}
});
PHP


根据Firebug的说法,答案是

{"ioutput":"<div class=\"iavatar\"><\/div>\n<div class=\"ititle\">What a lovely course<br \/>\n<div class=\"iauthor\">pm master<\/div><\/div>\n<div class=\"icontent\">This intimate layout, with its undulating and springy fairways that zigzag in amongst the woodland setting, calls for accurate driving and precision shot-making into the well-bunkered greens; another classic Colt trademark. Position, not power, is the name of the game here.<\/div>"}
{“ioutput”:“\n这是一个可爱的球场\npm大师\n这种亲密的布局,其起伏和弹性的球道在林地环境中曲折前进,需要准确的驾驶和精确的射门,这是柯尔特的另一个经典商标。这里的游戏名称是位置,而不是力量。”
但它会出错,不会将内容放入
#dbody

有什么想法吗?

尝试使用以下方法获得正确的错误:

$(function() {
    $.ajaxSetup({
        error: function(jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            } else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            } else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            } else if (exception === 'parsererror') {
                alert('Requested JSON parse failed.');
            } else if (exception === 'timeout') {
                alert('Time out error.');
            } else if (exception === 'abort') {
                alert('Ajax request aborted.');
            } else {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }
    });
});

如果Ajax调用中出现任何错误,您将得到适当的警告。

收到了什么响应代码?javascript错误是什么?我不知道。但它默认为上面的错误函数。为什么您要使用
json
来实现此目的?一个简单的
html
调用就足够了。从U结尾删除
?review
看看它是否有效。
{"ioutput":"<div class=\"iavatar\"><\/div>\n<div class=\"ititle\">What a lovely course<br \/>\n<div class=\"iauthor\">pm master<\/div><\/div>\n<div class=\"icontent\">This intimate layout, with its undulating and springy fairways that zigzag in amongst the woodland setting, calls for accurate driving and precision shot-making into the well-bunkered greens; another classic Colt trademark. Position, not power, is the name of the game here.<\/div>"}
$(function() {
    $.ajaxSetup({
        error: function(jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            } else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            } else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            } else if (exception === 'parsererror') {
                alert('Requested JSON parse failed.');
            } else if (exception === 'timeout') {
                alert('Time out error.');
            } else if (exception === 'abort') {
                alert('Ajax request aborted.');
            } else {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }
    });
});