请参见下面的代码:

$.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) {

最佳答案

strResponse = strResponse.toUpperCase;


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

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

09-11 20:44