1

I get this error when I load this page :

No 'Access-Control-Allow-Origin' header is present on the requested resource.

the page is this one : http://vieillemethodecorpsneuf.com/confirmation-achat-2/?item=2&cbreceipt=NT5LQ4FE&time=1412942198&cbpop=103E98FF&cbaffi=CELLULITEF&cupsellreceipt=NT5LQ4FE&cname=nathalie+huard&cemail=n-huard@hotmail.com&ccountry=CA&czip=J2J1M9&cbskin=6553&cbfid=14412&cbf=M3XLQ7WEWB

and complete error is this :

XMLHttpRequest cannot load https://app.getresponse.com/add_contact_webform.html?u=WOoS. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://vieillemethodecorpsneuf.com' is therefore not allowed access.

How can we solve this? Can I put something in the .htaccess file to resolve it?

Please be aware that this page is build under the Wordpress OptimizePress plugin and even if there's a module that can help me to put code in the HEAD section, OP do not allow me to render PHP code with this module. So it is hard to put this code in header:

<?php
header("Access-Control-Allow-Origin: *");

By the way, the complete code that is refering to is :

<?php
$clickbank_name = (isset($_GET['cname'])) ? $_GET['cname'] : ''; 
$clickbank_email = (isset($_GET['cemail'])) ? $_GET['cemail'] : '';
$clickbank_country = (isset($_GET['ccountry'])) ? $_GET['ccountry'] : '';
?>
<script type="text/javascript"    src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){  
var cname = '<?php echo $clickbank_name; ?>';
var cemail = '<?php echo $clickbank_email; ?>';
var ccountry = '<?php echo $clickbank_country; ?>';
var webform_id = '5068102'; //here your webform id

var dataString = ‘name='+cname+'&email='+cemail+'&custom_country='+ccountry+'&webform_id='+webform_id;
$.ajax({
  type: "POST",
  url: "https://app.getresponse.com/add_contact_webform.html?u=WOoS",
  data: dataString
});
});
</script>
Marty
  • 23
  • 2
  • 5

2 Answers2

0

If you call with jquery you should use "crossDomain:true"

for example:

$.ajax({    
    type: "GET",
    crossDomain:true,
    url: "http://api.pinterest.com/v1/urls/count.json",
    dataType: "jsonp",
    success: function(e) {
    }
});
0

This error is hard to get around if you do not have access to push code on the server and if you're pinging the server as a client (from frontend). The simplest way in my opinion is to use JSONP or to run your own sever which serves the frontend and also pings the remote server you're trying to access.

This might help too: So, JSONP or CORS?

Community
  • 1
  • 1
sleeping_dragon
  • 701
  • 1
  • 10
  • 27