0

I have to redirect with ajax to different domain. There is bank page. In Php I get adres to redirect when I use function header I got a error in ajax XMLHttpRequest cannot load so I want to pass this using echo and i changed dataType:"text", but I can not redirect. Please help me.

$.ajax({
                type: "POST",
                url: "/module/payu/paymentMethods",
                header:'Access-Control-Allow-Origin',
                data: '{ "name":"'+val+'" }',
                contentType: "application/json",
                crossDomain:false,
                success: function(data) {
                    console.log('Super' +val);
                },
                dataType:"JsoP",
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(jqXHR,textStatus, errorThrown);
                }

           });


echo ("<script>window.location.href='$url'</script>");
                      //  header("Location:".$url,true);

1 Answers1

0

you should add this header in your php page to allow request from any source , note that it is not good from security measure

header("access-control-allow-origin: *");
  • I always get the same message in console _italic_No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://prestashop.shop' is therefore not allowed access. header("Access-Control-Allow-Origin: *"); header("Location:".$url); – Bartosz Zieliński Jun 07 '16 at 11:34
  • XMLHttpRequest cannot load ...bank adres... – Bartosz Zieliński Jun 07 '16 at 11:40
  • you should add header("access-control-allow-origin: *"); in the requested file , but in your case you are using prestashop so should know what is the php file where you should add this header – hacene abdessamed Jun 07 '16 at 12:27