AJAX返回错误,返回空responseText

时间:2016-08-29 09:54:12

标签: javascript php jquery ajax

我试图通过AJAX获取一些数据但是得到一个空的responseText错误。

我的代码如下:

JS:

select AVG(totalRatings) from YOUR_TABLE where date=YOUR_DATE;

PHP:

function getFounder(id) {
    var founder = "";

    $.ajax({ 

        url: '/data/founder_info.php',
        data: {founder: id},
        dataType: 'json',
        async: false,
        type: 'post',
        success: function(json) {

            //founder = json.username;

            console.log(json);

        },
        error: function(ts) {
            console.log("Error: " + ts.responseText);
        }
    });

    return founder;
}

我无法找到导致错误的原因。

1 个答案:

答案 0 :(得分:0)

我使用一种方法将其修改为UTF-8。

function utf8ize($d) {
    if (is_array($d)) 
        foreach ($d as $k => $v) 
            $d[$k] = utf8ize($v);

     else if(is_object($d))
        foreach ($d as $k => $v) 
            $d->$k = utf8ize($v);

     else 
        return utf8_encode($d);

    return $d;
}

这是作为this question

的答案发布的

我的问题现在已经解决了!

相关问题