views:

18

answers:

0

Hi

I'm using the jquery.form plugin, it works except that I can't catch server errors. Even when I'm using the 'error' option, it doesn't seem to catch anything.

For example, if the server returns a 500 error code, it will still says 200 code, which means 'Ok'. So I can't do handle the 500 response at all. What's happening?

//Define ajax options
var options = {
    target: "#responsePanel",
    beforeSend: function(){
        $("#uploadingImg").show();
        $("#polygonUploadPanel, #polygonUploadBtnHolder").hide();
    },
    complete: function(){
        $("#uploadingImg").hide();
        $("#polygonUploadPanel, #polygonUploadBtnHolder").show();
    },
    success: function(response, statusString){
        $("#responsePanel").html(statusString);
        //map.polygonUploaded();
        $("#polygonUploadForm").hide();
    },
    error: function(response, statusString){
        $("#responsePanel").html(statusString);
        $("#polygonUploadPanel, #polygonUploadBtnHolder").hide();
        $("#polygonUploadBtn").hide();
        $("#ajaxUploadError").show();
        $(".errorHeading a").click(function(e){
            if($(".errorDetails").is(":visible")){
                $(".errorDetails").hide();
            }
            else{
                $(".errorDetails").show();
            }
        });

        $("#polygonUploadForm").show();
    }
};

$("#polygonUploadForm").ajaxForm(options);