Hello,

I am using jquery.ajax() to make a POST call to web server which
returns HTTP 201 response for successful creation of object at server.
Since 201 is a success I expect the success function specified with
jquery.ajax to execute but instead it executes the error function
specified with jquery.ajax. Here is how I am using jquery.ajax call.

request = '<user><name>SomeName</name></user>';
$.ajax({
    error:function(request) {
          alert('Error creating user');
    },
    success:function(xml, textStatus) {
          alert('success');
    },
    type: 'POST',
    contentType: 'application/xml;charset=UTF-8',
     url: server_root + '/management/users/',
     data: request
});

Does success function gets executed only for HTTP 200 Response or will
it be executed for HTTP 201 Response too?

In case success function gets executed only for 200 response, how can
I handle 201 response which is a success response?

Any help to resolve above issue is appreciated.

Thanks,
Regards,
Nitin

Reply via email to