Cumhur Yrdkl
Cumhur Yrdkl

Reputation: 21

Jquery $get or $post not coming response

$(document).ready(function(e) {
  $('body').load("http://www.sitemetre.net/_face/kaydet.php");;  
});

or like this usage not working

$(document).ready(function(e) {

  $.get('http://www.sitemetre.net/_face/kaydet.php', function(res){
       $('body').html("coming: "+res)
   })


});

can you check here problem http://referanslar.net/_face/deneme.php when i check from console. get or post workingin status coming ok but writen red text what is the problem?

Upvotes: 1

Views: 127

Answers (1)

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276306

You can't make cross domain AJAX requests without the site you're making the request from explicitly allowing it. The site must be on the same domain, protocols, ports and subdomains must match too.

XMLHttpRequest cannot load http://www.sitemetre.net/_face/kaydet.php. Origin http://referanslar.net is not allowed by Access-Control-Allow-Origin.

Possible solutions:

  • If you have access to the site you're loading from set up CORS there (CORS stands for cross origin resource sharing).
  • Alternatively, if you must support browsers that don't do CORS well like IE6 (sadly, some people still have to support that) you can make a JSONP request.
  • If you have no access to the site you're loading from, you can proxy it on PHP which would allow you to use it from your site which is not under same origin policy limitations. (Note, this is obviously possible with any other server side technology and not just PHP, but OP is already using PHP).

Upvotes: 2

Related Questions