0
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
       alert("jquery loaded");
       $.get('country.php?id=117',function(d){
               alert('something');
       });
})
</script>

Well the code is simple enough, and the "jquery loaded" alert comes up fine. Also as you can see, the page I am requesting is on the same server and domain, so there shouldn't be any cross browser issues to begin with. country.php simple does echo "hello world", and if I access the page in browser it displays without a hitch.

But when I try running that get method( I tried with POST as well), nothing happens. Firebug shows the request as OPTIONS instead of GET, and blank html response. This happens for every url I try, and in all browsers, any ideas?

by the way, here's the firebug headers log:

Response Headers
Connection  Keep-Alive
Content-Type    text/html
Date    Wed, 01 Feb 2012 13:04:56 GMT
Keep-Alive  timeout=5, max=75
Server  Apache
Transfer-Encoding   chunked
____________________________________________________________________________

Request Headers
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Access-Control-Request-He...    x-requested-with
Access-Control-Request-Me...    GET
Connection  keep-alive
Host    shikenan.com
Origin  https://shikenan.com
User-Agent  Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 FirePHP/0.6
x-insight   activate
Bluemagica
  • 5,000
  • 12
  • 47
  • 73

2 Answers2

0

I know you said it is same-domain,, but the OPTIONS part does suggests cross domain. Do you perhaps have a <BASE> tag in your HTML file?

See also this SO question

Community
  • 1
  • 1
Jochem
  • 2,995
  • 16
  • 18
0

try this

$(function(){
   $.ajax({
      url: "country.php",
      data: {id: 117},
      success: function(data){
      alert("something")
   }
  });
});
Yorgo
  • 2,668
  • 1
  • 16
  • 24