1
$(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?

  • You are getting a Access-Control-Allow-Origin. which means this is cross domain call. which `ajax` wont allow. – krishwader Aug 03 '13 at 18:43
  • Chrome developer console has this to say: XMLHttpRequest cannot load http://www.sitemetre.net/_face/kaydet.php. Origin http://referanslar.net is not allowed by Access-Control-Allow-Origin. Looks like you may have a rights issues – Leon Aug 03 '13 at 18:44
  • I'm pretty sure there is a duplicate for this question but I couldn't find it. If someone could find the duplicate that would be great. – Benjamin Gruenbaum Aug 03 '13 at 18:44

1 Answers1

2

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).
Community
  • 1
  • 1
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
  • You should include the info about Access-Control-Allow-Origin settings. The site can be prepared for such request by properly written OPTIONS response headers, thus it is possible. – Frizi Aug 03 '13 at 18:45
  • @Frizi This is a community wiki post. This means you own this post just as much as I do :) If you think this info could benefit the answer you're _very_ welcome to add it in. See http://meta.stackexchange.com/questions/11740/what-are-community-wiki-posts – Benjamin Gruenbaum Aug 03 '13 at 18:46
  • Huh, I was changing things, but you were faster :P – Frizi Aug 03 '13 at 18:51
  • @Frizi you can still (and should) make good changes. I was editing other stuff - like how to overcome the problem generally. – Benjamin Gruenbaum Aug 03 '13 at 18:52
  • I know I can, but that is exactly what I was going to change, but your formatting is better IMO. – Frizi Aug 03 '13 at 18:55
  • You can make a workarround, just make an ajaxcall to a localfile, sending the url as data, and make the phpfile return a file_get_contents() – Martijn Aug 03 '13 at 18:58
  • @Martijn Right, this is what I suggest in the third possible solution. If you'd like to elaborate on that feel free to edit the answer. – Benjamin Gruenbaum Aug 03 '13 at 19:02