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.
浙公网安备 33010602011771号