$.ajax json 在本地正常 上传服务器不正常

$.ajax( {  
                      url:"url",// 跳转到 action  
                      data:{name:name,b:b},  
                      type:'post',  
                      cache:false,  
                      dataType:'json',  
                      success:function(data) {  
                          if(data.status){  
                            alert(data.info);  
                            $('#chang-form').resetForm();
                          }else{  
                            alert(data.info);  
                          }  
                       },  
                       error : function() {    
                         alert("网络请求异常!");  
                       }  
               });

 

如上所示:在本地服务器正常   上传服务器不正常

方法一   json 类型换成 text   就可以正常运行

   $.ajax( {  
                url:"{:U('Exchange/change')}",// 跳转到 action  
                data:{"uname":uname,"pwd1":pwd1,"pwd2":pwd2,"gid":gid,"flowers":flowers,"__hash__":__hash__},  
                type:'post',  
                cache:false,  
                dataType:'text',
                async: false,  
                success:function(data) {
                    alert(eval("(" + data + ")"));
                    location.reload();  
                },  
                error : function(data) {    
                    alert('网络请求异常!');  
                    location.reload();  
                    
                }  
          });

方法二   将 http://cdn.bootcss.com/jquery/1.11.2/jquery.js    换成      jquery-1.8.3.min.js

 

posted @ 2017-03-29 11:04  smile001  阅读(454)  评论(0编辑  收藏  举报