Why does Cordova 2.7.0 JS seemingly no longer work on remote pages?

前端 未结 6 1467
执笔经年
执笔经年 2021-02-06 00:48

Background

I\'m attempting to upgrade an iOS app built on Cordova 2.0 to version 2.7.

It\'s basically a welcome screen that points to a remote search engine (p

6条回答
  •  粉色の甜心
    2021-02-06 01:19

    I had a similar problem relating to upgrading to Cordova 2.7. However my problem was all my console.logs stopped firing when running the app. I couldn't figure out why for the life of me this was happening. I thought it was because I upgraded jquery.mobile. That wasn't it. I then thought it was an .htaccess issue, that wasn't it either. It turns out, it was Cordova 2.7 that was causing this problem.

    I did try adding the .json file on my server, that did not fix the issue.

    The fix was going into the 2.7 source and commenting out the following code:

    /*comment out this as it is breaking console.logs
        var xhr = new context.XMLHttpRequest();
        xhr.onload = function() {
            // If the response is a JSON string which composes an array, call handlePluginsObject.
            // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
            var obj = this.responseText && JSON.parse(this.responseText);
            if (obj && obj instanceof Array && obj.length > 0) {
                handlePluginsObject(obj);
            } else {
                finishPluginLoading();
            }
        };
        xhr.onerror = function() {
            finishPluginLoading();
        };
        xhr.open('GET', 'cordova_plugins.json', true); // Async
        xhr.send();
        */
    

    Replace entire block with a call to the following function:

    finishPluginLoading();
    

    My logs are now working again. Only took me 3 days scratching my head.

    Hope this helps someone with a similar problem.

提交回复
热议问题