I need to check if it´s been possible to load an external page on a website, and display an alert depending on that result.
I have an Iframe, and I have been triying to detect the HTTP error code with Jqu开发者_如何学Goery, and I couldn't find the way, does anybody knows how?
Thank you.
If you are trying to get content from some other domain, like for ex. from exampleA.com to exampleB.com using ajax, it will not work. Cross domain ajax request is prohibited by browser policy.
The same will go with iframe too. If you have an iframe which loads content from some other domain, you can not manipulate the content of the iframe using javascript.
A possible solution would be to use a server side proxy script. You need to write a server side script which loads the external website's content and you can request the script using ajax. As the script is running from your domain, you can request it from ajax.
If you are using php, you can use curl
to load the external website's content from your php proxy script and call the proxy script using ajax.
I would use Ajax (with the help of some backend coding to actualy check the status) for that.
精彩评论