1

这是代码

var dataStore = (function () {
var _0x68ccx52;
$['ajax']({
        type: 'GET',

            url: 'xml/langSelectionsBeta.xml',
            dataType: 'xml',
            success: function (_0x68ccx2c) {
                alert("success");
                _0x68ccx52 = _0x68ccx2c;
            }
        });
    return {
        getXml: function () {
            if (_0x68ccx52) {
                return _0x68ccx52;
            }
            else{
                alert("FAIL");
                return _0x68ccx52;
            }
        }
    };
})();

var data = dataStore['getXml']();

除刷新整个页面外,始终可以加载数据;“失败”总是显示在“成功”之前。有没有刷新页面的方法?

4

1 回答 1

1
        $['ajax']({
            type: 'GET',
            url: 'xml/langSelectionsBeta.xml',
            dataType: 'xml',
            success: function (data) {
                dataStore.getXml = function () {
                    return data;
                };
                //function that you want to do after receiving the data
                //eg. setLanguage(_0x68ccx10);  
            }

        });
于 2013-06-06T20:28:16.533 回答