Can't load Google Cloud Endpoints on Internet Explorer 10

后端 未结 3 1549
独厮守ぢ
独厮守ぢ 2021-02-13 15:49

I\'m working on a web site that is using the Google JavaScript Client Library to load some APIs that are exposed via Google Cloud Endpoints. The endpoints were developed in Pyth

3条回答
  •  孤街浪徒
    2021-02-13 16:31

    Hope it can help :


    var executeRequest = function(path, data, callback, method){
        var url = ‘YOUR_API_LINK' + path;
        $.ajax({
            url: url,
            type: method,
            dataType: 'json',
            data: data?data:null,
            success: function(data, status, xhr) {
            },
            error: function(xhr, status, error) {
            },
            complete: function(xhr, status) {
                var data = null;
                console.log('Request ' + url + ' completed');
                if (xhr.responseText && xhr.responseText.length > 0) {
                    data = $.parseJSON(xhr.responseText);
                }
                if (callback)
                    callback(data);
            }
        });
    };
    
    ---------------
    
    Simple call example of this function made in the same file :
    
    ---------------
    
    var simpleGetUser = function(userKey, callback){
        this.executeRequest(
        '/user/v1/user/' + userKey,
        {/* If you got any parameters, put them here */},
        function (res) {
            if (callback)
                callback(res);
        }, 'GET');
    };
    

    Good luck !

提交回复
热议问题