求助!!!关于mui ajax获取不到后台数据

js代码如下
<script>

        mui.init();
        mui.ajax('ajax.php', {  
            dataType: 'json', //服务器返回json格式数据  
            type: 'post', //HTTP请求类型
            headers: {                'Content-Type': 'application/json'  
            },     
            success: function(data) {  
                alert(data)//就像获取后台php的数据啊!!!
            },            async:true, 
            error: function(xhr, type, errorThrown) {
                alert(errorThrown);//好像报类型错误?php那边是json格式啊
            }
        });    </script>

php代码如下
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
//header("Content-type: text/html; charset=utf-8");
header('Content-type: text/json; charset=utf-8');
//header('Content-type: application/json');
//这个header头有点疑问~所有都试了一遍还是没用
$arr = array(

'name' => '我是姓名', 
'age' => '18'

); 
$json_string = json_encode($arr); 
echo ($json_string);//这里输出就是json字符串了啊~~
?>

手机端就是报错~而浏览器到是能正常获取数据是在搞不定了求解~我就是想获取php内的json数据啊~~


蓝山帝景
浏览 1235回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript