Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XHR object doesn't keep the original response status code #3

Open
pparidans opened this issue Sep 22, 2011 · 2 comments
Open

XHR object doesn't keep the original response status code #3

pparidans opened this issue Sep 22, 2011 · 2 comments

Comments

@pparidans
Copy link

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.

@cmlenz
Copy link
Owner

cmlenz commented Nov 11, 2011

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.

@JangoSteve
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants