tp 获取ajax总是出问题,求解

浏览:470 发布日期:2016/07/04 分类:求助交流 关键字: thinkphp ajax返回
test.html :

$.get("__URL__/test",{},function(data){
console.log(data);
});

IndexAction :

public function test(){
echo json_encode(array("test"=>"this is a test"));
}

test.html 中打印出来的 data 是 </script> this is a test ,前面总是跟着 </script>

然后我不用tp,直接提交给同目录下的.php:
test.html :

$.get("tt.php",{},function(data){
console.log(data);
});

tt.php :

<?php

echo json_encode(array("test"=>"this is a test ~~~"));

最后输出的data是:json : {"test":this is a test ~~~"}

我的是mac系统,在另一台windows环境中的tp上运行是正常的,为啥我这电脑上的tp就是不行?真的搞不懂~~~请各位大神解答一下~~~

最佳答案
评论( 相关
后面还有条评论,点击查看>>