1

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);
    }

    if (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);
    }
},
1
  • Sometimes errors are spurious. I have seen this 'function expected' error in Visual Studio 2010 with IE10 and could not see anything wrong with my code; I opened the page in Firefox/Firebug and it ran fine. Commented Sep 11, 2013 at 13:59

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

While maybe a helpful troubleshooting suggestion, this is hardly an answer. It should be a comment on the OP.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.