对象不支持使用AJAX的此属性或方法

时间:2015-10-26 14:52:23

标签: javascript jquery internet-explorer-11

请参阅以下代码:

$.ajax({
    type: "POST",
    url: "Results1.aspx/TableQuery",
    data: JSON.stringify({
        mappingid: res[i],
        strCon: $("#fieldGenieConnectionString")[0].value,
        strTypeSession: $("#fieldTypeSession")[0].value
    }),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess(i, res.length),
    error: OnError,
    failure: function (response) {
        alert('there was a failure loading the webpage')
    }
});

以及以下代码:

function OnSuccess(i, totalrows) {
    return function (response) {
        //if (response.d != "") {
        var strResponse = response.d;
        strResponse = strResponse.toUpperCase;
        if (strResponse.indexOf("<TR>") > 0) {
            // alert(response.d);
            document.getElementById('div' + i).innerHTML = document.getElementById('div' + i).innerHTML + '<br>' + '<br>' + response.d;
        }
        numSucceeded++;
        var completeCalculation = (numSucceeded / totalrows) * 100
        var rounded = completeCalculation.toFixed(0);
        document.getElementById('ProgressIndicator').innerHTML = rounded + ' % complete';
        document.getElementById('ProgressIndicator2').innerHTML = rounded + ' % complete';
        if (numSucceeded === totalrows) {
            var end = new Date().getTime();
            var htmlResponse = "Loaded after: " + (end - start) / 1000 + " seconds"
            document.getElementById('TotalTimeLabel').innerHTML = htmlResponse;
            document.getElementById('TotalTime2Label').innerHTML = htmlResponse;
            $("#LoadingImage").hide();
            $("#LoadingImage2").hide();
        }
    }
}

以下行会导致错误:

if (strResponse.indexOf("<TR>") > 0) {

1 个答案:

答案 0 :(得分:4)

strResponse = strResponse.toUpperCase;

这里有一个错字。我想你想写strResponse = strResponse.toUpperCase();

您正在为strResponse分配一项功能,而不是在现有的toUpperCase()上调用strResponse