lafer
lafer
  • 发布:2014-12-09 17:29
  • 更新:2014-12-09 21:58
  • 阅读:2362

过了一天ajax请求成功不执行了

分类:MUI
mui

过了一天ajax不执行回调了,前天还是好的

var success = function(response){  
    alert(1)  
    var dataType = "json";  
    if (dataType === 'json') {  
        response = JSON.stringify(response);  
    } else if (dataType === 'xml') {  
        response = new XMLSerializer().serializeToString(response).replace(/</g, "&lt;").replace(/>/g, "&gt;");  
    }  
    alert(response)  
    var table = document.body.querySelector('.mui-scroll');  
    var cells = document.body.querySelectorAll('.ne-list');  
    for (var i = cells.length; i < eval(response).length; i++) {  
        var li = document.createElement('a');  
        li.className = 'ne-list';     
        li.href = 'new-info.html';  
        li.setAttribute('data-id',eval(response)[i].id);  
        li.innerHTML = '<img src="'+eval(response)[i].smeta+'"><div class="ne-txt"><h3><span>'+eval(response)[i].post_title+'</span><em>'+eval(response)[i].post_date+'</em></h3><p>'+eval(response)[i].post_excerpt+'</p></div>';  
        table.appendChild(li);  
    }  
}  

                var ajax = function(){  
                    var url = "http://www.wedofi.com/index.php";  
                    var type = "get";  
                    var dataType = "json";  
                    var data = {  
                        g : "portal",  
                        m : "index",  
                        a : "app_news"  
                    }  

                    if (type === 'get') {  
                        if (dataType === 'json') {  
                            mui.getJSON(url, data, success);  
                        } else {  
                            mui.get(url, data, success, dataType);  

                        }  
                    } else if (type === 'post') {  
                        mui.post(url, data, success, dataType);  
                    }  
                }  

                ajax();
2014-12-09 17:29 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

确认一下是不是plus环境不具备,换成如下方式试试:

mui.plusReady(ajax);
lafer

lafer (作者)

mui.plusReady(function(){


});

放在这个里面的

lafer

lafer (作者)

前两天还可以用 今天打开就不行了

DCloud_UNI_CHB

DCloud_UNI_CHB

是不是服务器变动了?在服务端使用jQuery也无法访问;

var url = "http://www.wedofi.com/index.php";  
var data = {  
        g : "portal",  
        m : "index",  
        a : "app_news"  
 }  
jQuery.getJSON(url,data,function () {  
    console.log("ajax success");  
})

在服务端检查一下Access-Control-Allow-Origin设置吧。

lafer

lafer (作者)

但是我直接访问
wedofi.com/index.php?g=portal&m=index&a=app_news
这个地址又可以呢

lafer

lafer (作者)

找到问题了 就是服务器的问题

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