0

I am trying to call a php file which is located on a webserver(1freehosting.com) from ajax code which is present in an html file located on my localhost machine (wamp). I tried all diffrent iteration given below but non seems to be working.

xmlhttp.open("GET","bcbustransit.uni.me/getdirection.php?q="+str.value,true);
xmlhttp.open("GET","http://bcbustransit.uni.me/getdirection.php?q="+str.value,true);
xmlhttp.open("GET","http://www.bcbustransit.uni.me/getdirection.php?q="+str.value,true);

When i upload the same html file on the same webserver(1freehosting.com) and then make a call it works as specified below.

xmlhttp.open("GET","getdirection.php?q="+str.value,true); 

How can i make a call to a php file on a webserver from my localhost machine ? Is there something i am doing wrong

dev_marshell08
  • 1,051
  • 3
  • 18
  • 40
  • 2
    Look up something called the "same origin policy." That's very likely what you're facing here. – David Mar 03 '14 at 23:35

1 Answers1

1

Check this question Same Origin Policy - AJAX & using Public APIs It should be the same problem and has a solution for your problem.

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66