On my local machine all Ajax requests work just fine and the app works perfectly. It is a different story on the host machine. When trying to execute below Ajax script I get :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://googleads.g.doubleclick.net/pagead/id. (Reason: CORS request did not succeed).
I spent all day trying to fix this error to no avail. I even added this in the head of every page
<?php ob_start();
header('Content-Type: text/html; charset=utf-8');
header("Access-Control-Allow-Origin: *");
?>
I read about JSONP and I'm wondering how to implement this solution?
This is the short version of the Ajax
$( ".submit-signup-form" ).click(function(e) {
e.preventDefault();
if(formvalues!==''){
$("#sign-up-form-2").submit(
$.ajax({
type: "POST",
url: 'queries/register.php',
data: formvalues,
success: function(customerarr){ //callback}
})
})
});
}
When debugging the app in the console I tried console.log(formvalues)
and everything printed out okay. The form does get ALL the variables so I'm not understanding how to make the script work on live host.