Cross domain exception

2019-08-28 06:12发布

问题:

I uploaded my wordpress blog on url : http://blog.in

I am getting cross domain exception while calling following url

                $.ajax({
                          type: "POST",
                          url: "http://app.blog.in/getToken",
                          contentType: "text/html",
                              success: function(msg) {
                                            alert(msg);
                          }
                    });

Please suggest me

Thanks

回答1:

Since you are loading from a different subdomain, browser security doesn't allow that. Unless you can move the data you're loading to the same domain (that's same subdomain as well), you should look into using JSONP. Then you can load data from anywhere.



回答2:

You are getting a cross-domain error because you are crossing domains: app.blog.in and blog.in. You should serve the content from the same domain as where you post it.