detecting returned errors with $.post

Posted by sova on Stack Overflow See other posts from Stack Overflow or by sova
Published on 2010-12-29T00:39:10Z Indexed on 2010/12/29 0:54 UTC
Read the original article Hit count: 217

Filed under:
|

I'm using $.post to send a query to a JSP which returns some awesome data for me.

If the query is malformed, however, the page returns with "error on page" and an HTTP Status of 500 Internal Server Error

in jQuery, how can I detect this error so I can tell the user of the failure?

 runQuery : function () {
    $.post(
        admin_stats.runQueryURL,
        {
            buster   : Math.random,
            statsQuery: admin_stats.getQuery(),
            jsp: 'admin_statsQuery'
        },
        admin_stats.handleStatsQuery,
        "html"
    );

the returned data is an HTML table which is sufficient for this project at the moment.

Also: totally open to criticism if this is ugly or not the way I should be doing things =)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about http-post