开发者

JavaScript error "Function expected" in if statement

开发者 https://www.devze.com 2023-03-24 02:01 出处:网络
When I click the button on the page I am getting a \"Function Expected\" error message. The error is on the first 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

精彩评论

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