jquery-iframe-transport icon indicating copy to clipboard operation
jquery-iframe-transport copied to clipboard

XHR object doesn't keep the original response status code

Open pparidans opened this issue 13 years ago • 2 comments

When I do the request its response's status and statusText are still 200 and "OK" even if the server side script return a 500 error (or anyother error code).

Anyway, the response content is fine.

pparidans avatar Sep 22 '11 10:09 pparidans

Unfortunately there's no way that I know of to get the status code of a response loaded through an iframe. See for example http://stackoverflow.com/questions/35240/retrieving-http-status-code-from-loaded-iframe-with-javascript.

cmlenz avatar Nov 11 '11 17:11 cmlenz

To expand on what @cmlenz is saying, you need to do some server-side scripting to detect when your form has been submitted via the jquery-iframe-transport's iframe, and have it return the response status and code in the body of your response so that your front-end code can parse it out.

For example, the remotipart gem does exactly this in Rails via a Rack Middleware, so that you don't need any custom code in your app to do this.

And when you use the textarea response as above, you don't need to do anything special in your front-end code since the iframe-transport.js automatically detects when the response is a textarea and parses the status code, etc. for you.

JangoSteve avatar Jul 06 '13 16:07 JangoSteve