IE7的Jquery Web服务请求>和Safari

时间:2012-03-28 01:41:08

标签: jquery json web-services

我正在使用带有JQuery的Web服务,响应是JSON格式。我已经开发了Chrome和Firefox的请求,它工作正常,但IExplorer 7>和Safari不起作用。我已经搜索过了,我还没有看到任何有用的方法来实现它。 你知道如何解决这个问题吗? 这是我的代码:

// To Know if browser is chrome
var chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

//Set client ID
var ID = "ABC123";

$.ajax({
            url: 'http://www.../generateSession',
            data: "id=" + ID,

            beforeSend: function( xhr ){
                //Show waiting div
            },

            success: function( data ) {


                if (console && console.log){
                    var json = null;
                // if browser is chrome, then use parseJSON 
                if(!chrome) {
                        json = $.parseJSON(data);
                    } else {
                        json = data;
                    }

            sessionStorage.setItem("SID", json.sessionId);
            console.info("Fetched session id " + json.sessionId)
            // … hide waiting div
} ///Session created
    }, error : function() { 
                alert("Error, please try again");
            }

        });     
}

0 个答案:

没有答案
相关问题