Php jQuery+;IE8 Ajax Json解析错误

Php jQuery+;IE8 Ajax Json解析错误,php,jquery,Php,Jquery,我有一个使用jQuery通过$.ajax()调用服务器的脚本,它在Chrome或FF上运行良好,但在IE 8中不起作用 这是我的电话: $.ajax({ url: 'location.php', dataType: 'json', success: function(data){ alert('Ajax made!'); $.each(data, function(key, val) { var lat = null; v

我有一个使用jQuery通过$.ajax()调用服务器的脚本,它在Chrome或FF上运行良好,但在IE 8中不起作用

这是我的电话:

$.ajax({
  url: 'location.php',
  dataType: 'json',
  success: function(data){
      alert('Ajax made!');
      $.each(data, function(key, val) {

         var lat = null;
         var lng = null;
         var title = null;
         var id = null;

         $.each(val, function(index, vol) {

            if(index == 'id')
                id = vol;
            else if(index == 'lng')
                lng = vol;
            else if(index == 'lat')
                lat = vol;
            else if(index == 'nombre')
                title = vol;    
         });

                     // Create marker in the Google Map
         createMaker(id,lat,lng,title);
      });       
  },
  error: function(jqXHR, textStatus, errorThrown){
            // I get Error on IE 8
    alert(jqXHR.responseText);
  }
});
这是服务器端的代码:

    header( 'Content-type: application/json' );

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Existe un problema al  conectar a la base de datos. Disculpe las molestias');
mysql_select_db($dbname);
    mysql_query('SET CHARACTER SET utf8');
    $result = mysql_query("select id,lat,lng,nombre from location");


$rows = array();
while($r = mysql_fetch_assoc($result)) {
    $rows[] = $r;
}


print json_encode($rows);

// close the connection
mysql_close($conn);
结果json如下所示:

[{“id”:“3”,“lat”:“19.700800”,“lng”:“-101.186972”,“nombre”:“Victor Manuel Mendoza Armas”}]

不知道为什么我的php会在响应的顶部添加


也许这就是问题所在?

我在google app engine中遇到过类似的问题,但在python中遇到了类似的问题。


看起来,如果您有一些随机打印语句,这就是原因。可能与PHP相同。

在该PHP脚本上,我只打印了一个json_encode($rows),没有其他内容。不知道为什么PHP会在响应开始时发送该消息。是否有可能输出这些HTML注释的包含文件?是的,这就是问题所在,我包含了一个PHP,它有一个HTML注释。谢谢