今非昔比
今非昔比
  • 发布:2016-04-28 17:02
  • 更新:2016-04-28 17:05
  • 阅读:1992

Bbuilder mui里的ajax 请求时发送的json数据出错 "parsererror"

分类:HBuilder

<script type="text/javascript" charset="UTF-8">
mui.init();
mui.ready(function(){
mui.plusReady(function(){

            m_id=plus.storage.getItem('m_id');  
            document.getElementById('m_id').value=m_id;  
            mui.ajax(server+'index.php/Mobile/User/edit_user_info',{  
                data:{  
                    m_id:plus.storage.getItem('m_id')  
                },  
                dataType:'json',  
                type:'get',  
                timeout:10000,  
                success:function(data){  

                    if(data.code){  
                        console.log(data.info.pic_path);  
                        if(data.info.pic_path != 'Uploads/Image/Mobile/'){  
                            document.getElementById('image').src=server+data.info.pic_path;  
                        }  

                        if(data.info.username){  
                            document.getElementById('username').value=data.info.username;  
                        }  

                        if(data.info.sex){  
                            var sex=document.getElementById('sex');  
                            for(var i=0;i<sex.options.length;i++){  
                                if(data.info.sex==sex.options[i].value){  
                                    sex.options[i].selected='selected';  
                                    break;  
                                }  
                            }  
                        }  

                        if(data.info.birthday){  
                            document.getElementById('birthday').value=data.info.birthday;  
                        }  

                        if(data.info.job){  
                            var job=document.getElementById('job');  
                            for(var i=0;i<job.options.length;i++){  
                                if(data.info.job==job.options[i].value){  
                                    job.options[i].selected='selected';  
                                    break;  
                                }  
                            }  

                    }else{  

                    }  
                    }  
                },  
                error:function(xhr,type,errorThrown){  
                    mui.alert(type);  
                }  
            })  
        })  
    })  

     function selectImage(file){  
        if(!file.files || !file.files[0]){  
            return;  
        }  
        var reader = new FileReader();  
        reader.onload = function(evt){  
            document.getElementById('image').src = evt.target.result;  
            image = evt.target.result;  
        }  
        reader.readAsDataURL(file.files[0]);  
    };  
    </script>
2016-04-28 17:02 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

排查服务端返回数据格式是否是正确的json格式

该问题目前已经被锁定, 无法添加新回复