I need to send a post request from the server of my intranet to the server of my external webpage. Using the jquery .post method I have been able to do this in chrome but it doesnt work in IE. Through research and testing I have isolated the issue to be that I am sending the post to an page on another server. Is there any way to get around this in IE?
Asked
Active
Viewed 206 times
1 Answers
1
Yes, you definitely can do it.
Modern browsers restrict cross domain ajax as it is a big security risk. However there are ways to to do it.
First of all, place the .js file containing the ajax request on a server on which you want to post the data
next, include the file in your current site - i.e. the site from where you want to post but do not keep the file in the same domain, rather link it from the domain to where you want to post.
Make the ajax request using the code in the js file and you are ready to go.
- Essence of the story is, to ensure that a web page is posting data to a place which is either owned by the domain in which the page is or is in control of that domain, such an restriction is placed.
Another way is to explicitly allow cross domain ajax by these directives as explained in this answer
Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com/
on target server
in php:
header("Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com/");
and to your .htacess file add
Header set Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com/

Community
- 1
- 1

Murtuza Kabul
- 6,438
- 6
- 27
- 34