Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

XMLHTTP Cross-domain not works in Firefox 3

I have a code which sends data to 3rd party website using JavaScript XMLHTTP POST and puts output in textbox for user.

It works on IE but in Firefox 3 I get permission denied, it's because I call to 3rd party website, what can I do?

What's solution for it?

Thanks from now!
0
CSecurity
Asked:
CSecurity
  • 2
1 Solution
 
hieloCommented:
>> it's because I call to 3rd party website
Yes

>>what can I do?
create a new page on your server called proxyPage.php and call YOUR proxyPage.php instead of the third party page directly. Assuming you are sending username="Joe" to YOUR proxyPage.php, then your script would be:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.remotesite.com/script.php');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=" . urlencode($_REQUEST['username']) );
$data = curl_exec($ch);
curl_close($ch);

//now send the result back to the ajax call:
echo $data;
exit;
?>
0
 
CSecurityAuthor Commented:
I did it, I coded everything without checking my server have CURL or no!!

What can I do now? My server doesn't have CURL
0
 
hieloCommented:
find out if you can make outbound calls. If not, you have reached a dead end. Some webhost companies do NOT allow outbound connections.
If you ARE in fact allowed to make outbound connections, see what other alternatives you have ex: is this an IIS server, if so you may be able to use a MSXML2.Server object. If you are in a non-windows environment, then see if they have perl available and seek a perl solution.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now