Stupid IE process 'application/json' content-type.

Let's see the snippets first.

jQuery

$.ajax({
  
'url': 'http://aptana-local/testobject/test1.php',
  
'dataType': 'json',
  
"success": function(data){   alert(data); console.log(data); console.log(typeof data); }
});

PHP (test1.php)

echo $this->_sendResponse($arr);
private
function _sendResponse($arr) { header('HTTP/1.1 200 OK'); header('Content-type: application/json; charset: UTF-8'); // COMMENT THIS LINE. echo CJSON::encode($arr); Yii::app()->end(); }

Js won't get 'data' in IE. We have to comment that line or change the "Content-type"  in PHP file.

posted on 2012-11-22 16:07  技术员  阅读(912)  评论(0)    收藏  举报

导航