开发者

JavaScript error "Function expected" in if statement

When I click the button on the page I am getting a "Function Expected" error message. The error is on the first if statement.

I have the following code:

Response_Error: function (xhr, textStatus, errorThrown) {
    if (textStatus && (textStatus == 'error' || textStatus == 'parsererror')) textStatus = '';
    if (errorThrown && errorThrown == 'error') errorThrown = '';
    var html = '';
    try {
        html = (textStatus ? 'textStatus: ' + textStatus + '<br/>' : '') +
            (errorThrown ? 'errorThrown: ' + errorThrown + '<br/>' + '<br/>' : '') +
            (textStatus || errorThrown ? '' : '<hr/>') + xhr.responseText;
    }
    catch (err) {
        document.write(err.description + '<br/>' + xhr.responseText);
    }

    i开发者_Python百科f (Page._lastModalDialog) {
        try {
            if (false) { // HACK: change this to true to put contents on a textarea
                html = html.replace('<', '&lt;').replace('>', '&gt;');
                html = "<form><textarea rows='40' cols='120'>" + html + "</textarea></form>";
            }
            $(Page._lastModalDialog).html(html).fadeIn("slow");
        }
        catch (err) {
            document.write(err.description + '<br/>' + html);
        }
        Page._lastModalDialog = null;
    }
    else {
        document.write(html);
    }
},


You can determine the line that have the error from the chrome inspector console or from fire bug and i think it hase something to do with providing a variable while a function is expected.


This is usually the case when a callback function is expected. Check the code and see if there is place where one of the parameters should be a callback function. You could also do a console.log xhr.onreadystatechange, to see if there is a callback assigned to the xhr object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜