Reputation: 2918
I'm trying to detect server information using only JS such as HTTP response code & content.
Because of Same-origin policy I'm not allowed to use normal ajax request and therefore i'm forced to following workarounds
Using JSONP is great but in case of error I can't know what HTTP code or content of response page
Using Image request is not really option cause, same as above, I can't know HTTP code or content. I can only know if I loaded image to DOM.
Using AJAX with CORS. This is best solution so far but in case it is not my server I can't detect HTTP code :(. Same applies for flash and crossdomain.xml policy.
Using iframe, as i know I can't detect HTTP code or content.
While writing this I've just notice that I'm dealing with XSS issues here but all I need from JS is HTTP code OR content of another domain.
All suggestions are welcome.
Upvotes: 0
Views: 107
Reputation: 43718
I fear that is not possible using client-side JavaScript, unless the server implements a mechanism allowing you to gather this information by either simply supporting CORS or include the information in the JSON response of the JSONP request.
However, if you have some server-side support you could put in place an API that allows you to do so. E.g. You call a service on your server which in turn performs the request on the remote server and returns the desired information.
Upvotes: 1