语法错误仅针对Jelly bean电话的意外令牌

时间:2015-05-25 04:02:04

标签: javascript jquery ajax html5 android-4.2-jelly-bean

我有一个基于HTML5的Android应用程序。该应用程序运行良好,能够从后端系统获取数据。但是,从今天起,应用程序在获取数据时报告了一个奇怪的错误:SyntaxError Unexpected token并显示一些乱码。此错误仅在具有Jelly Bean(Android 4.2.1)的手机上发生;它在上周工作得很好,代码没有变化。在下面的代码中,ajax调用进入Android 4.2.1的错误部分。

function getData() {
    jQuery.support.cors = true;
    $.ajax({
        type: "GET",
        beforeSend: function(xhr) {
            xhr.setRequestHeader('Content-Type', 'application/json;charset=utf-8');
            xhr.setRequestHeader('X-SMP-APPCID', connectionID);
            xhr.setRequestHeader('Authorization', 'Basic ' + btoa(appUser + ":" + appPass));
        },
        url: calURL, //calURL is the connection to backend
        crossDomain: true,
        dataType: "json",
        processData: false,
        xhrFields: {
            withCredentials: true
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("Error fetching Data - " + errorThrown);
            hideMainContent(false);
            document.getElementById("data").innerHTML = "Error fetching data - " + errorThrown;
            if(errorThrown.indexOf("Unauthorized") > -1){**// Invalid token reported here**
                document.getElementById("setButton").innerHTML = "<p>Unauthorized error can occur if your password has expired or changed. Below option can be used to change application password to your new Password.</p><button onclick=\"changePassword()\" class=\"ui-btn style=\"margin:10% 25%;width:50%;\">Change Password</button>";
            }
            else{
                document.getElementById("setButton").innerHTML = "<p>Temporary communication error. Please refresh after some time.</p>";
            }
        },
        success: function(jsonData) {

        },
    });
    return;
}

Error Image 1 Error Image 2

对此方面的任何帮助表示高度赞赏。

谢谢!

0 个答案:

没有答案