Home > Jquery Ajax > Jquery Ajax Post 201 Error

Jquery Ajax Post 201 Error

EDIT - Also you should probably use a different response, many use 200 - OK, but Id recommend to use 202 - ACCEPTED in this case. Reload to refresh your session. I spent days on this! Event though I got status-response 201 and the data is successfully inserted into my database, the system still regard it as an error and gives me "failed" alert? http://canondrivebh.com/jquery-ajax/ajax-jquery-post.html

Desjardins, and do not necessarily reflect those of Microsoft Corporation. An alternative is to explicitly call out the statusCode: $.ajax({ statusCode: { 201: function() { console.log("HERE"); } } }); share|improve this answer answered Feb 20 '13 at 20:00 Keith Rousseau 3,46311224 Any ideas of why it wouldn't be working? And I respect your take on it.

HTH. HTH. Check out this SOF thread on it: Problems Reading the HTTP Status/Error Code from jQuery AJAX share|improve this answer answered Sep 13 '12 at 15:49 Austin DeVinney 98210 add a comment| What happens if one brings more than 10,000 USD with them into the US?

You signed in with another tab or window. Gender roles for a jungle treehouse culture Check if a file exists on a remote machine with spaces in the filename and/or path 4 dogs have been born in the same Note: The above code is in coffeescript, which doesn't really affect the question but explains my syntax jquery coffeescript jquery-deferred share|improve this question edited Feb 20 '13 at 20:02 adeneo 207k13156204 How exactly std::string_view is faster than const std::string&?

But sometime, you may want to return handled error this way because you "control" the situation and do something else for unhandled error. How do I make a second minecraft account for my son? Is there any reason why done wouldn't fire for a 201 or 202? –justNeph Feb 20 '13 at 20:07 Like I said, based on the source it appears that You can fix it in jquery via the ajaxSetup method with the following code: $.ajaxSetup({dataFilter: function(data, type) { if (type == "json" && data == "") { data = null; }

You can fix it in jquery via the ajaxSetup method with the following code: $.ajaxSetup({dataFilter: function(data, type) { if (type == "json" && data == "") { data = null; } Join them; it only takes a minute: Sign up .ajax call “fails” on a 201 created but succeeds “done” if async==false up vote 2 down vote favorite Using Jquery 1.9.1 I Not the answer you're looking for? p.s.

What is a Waterfall Word™? It would seem that having an empty response return None instead of an empty string would solve the issue and maintain backwards compatibility with older versions of jQuery. How does a Spatial Reference System like WGS84 have an elipsoid and a geoid? Would it be possible to return "valid" JSON for these operations?

It could be an error somewhere else,try to step through httpSuccess function.// Determines if an XMLHttpRequest was successful or nothttpSuccess: function( xhr ) {try {// IE error sometimes returns 1223 when weblink Type the characters you see in the picture below. Who is the highest-grossing debut director? What does a profile's Decay Rate actually do?

Is it better form to just return a 200 manually then? –justNeph Feb 20 '13 at 20:01 1 Does it work if you change it to 200? –Keith Rousseau Feb would love to hear more ideas thank you all $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", url: "http://localhost:49223/Form/WebDataService.svc/XMLForm(guid'1eaef3a0-d6df-45bf-a8f6-3e7292c0d77e')/XMLRecord/", data: JSON.stringify(record), complete: function(xhr) { if (xhr.readyState == 4) { if (xhr.status Here's the jQuery code to reproduce. http://canondrivebh.com/jquery-ajax/jquery-ajax-post.html If you are writing the tasypie service jsonp is not likely what you are really doing also the datatype is not text but rather json.

Why do people move their cameras in a square motion? Regards Stefan comment:3 Changed 6 years ago by jaubourg jQuery doesn't "get confused" at all: ​http://jsfiddle.net/J2WxM/1/ Are you sure the code in your success handler doesn't throw an exception? How do you grow in a skill when you're the company lead in that area?

Older versions of jQuery handled null, undefined, and '', returning null for all three.

share|improve this answer answered Jan 14 at 12:43 Herberth Amaral 1,47922027 add a comment| up vote 0 down vote Data inserted successful but jquery still returning error The answer here appears Conditional summation Referee did not fully understand accepted paper Repetitive carvings around a sphere What does a profile's Decay Rate actually do? Equation which has to be solved with logarithms Is it possible to keep publishing under my professional (maiden) name, different from my married legal name? it was extremely annoying making 4 spaces before each line in the above output.

What to do with my out of control pre teen daughter Sci-fi/Drama/Mystery movie with mini-stories and paintings that affect humans LED on the collector without a base limiting resistor Can you Thank you Charlie Kaiman Sent via mobile … On Dec 4, 2013, at 8:59 PM, "Sam Kuehn" ***@***.***> wrote: Sounds like the other solution will work too but you are “tricking” I've looked at request/response and they are good. http://canondrivebh.com/jquery-ajax/jquery-ajax-post-example.html Related 4951How to check if an element is hidden in jQuery?5679How to redirect to another page in jQuery?255How can jQuery deferred be used?294jQuery deferreds and promises - .then() vs .done()68what is

How to create a backslash fraction? Are Employers Allowed to ask if I am Job Searching? Reload to refresh your session. Can you maybe submit a link to a reduced test case (some website which sends the appropriate headers), that reproduces the issue you are experiencing.

Also you will probably have to make this change on every ajax call. success: function(data){ $('#messageText').text('SMS successfully sent'); }, error: function(jqXhr){ data = JSON.parse(jqXhr.responseText); } javascript jquery share|improve this question asked Sep 13 '12 at 15:43 Prometheus 3,6131257136 add a comment| 4 Answers 4 From: Sam Kuehn [mailto:[email protected]] Sent: Wednesday, December 04, 2013 6:50 PM To: toastdriven/django-tastypie Cc: ckaiman Subject: Re: [django-tastypie] Empty response in POST, PATCH and DELETE requests throws (json) parse error in Or link?