开发者

HTTPrequest is not working

I'm trying to use an ajax request to connect, and gather data from, a PHP file. THe AJAX JS is on a different website than the PHP, just an FYI.

Here is the JS:

var quer;
 try
 {
  quer = new XMLHttpRequest();//I'm running in safari, so this gets called.
 } 
 catch (e)
 {
  try
  {
   quer = new ActiveXObject("Msxml2.XMLHttp");
  }
  catch (e)
  {
   try
   {
 开发者_如何转开发   quer = new ActiveXObject("Microsoft.XMLHttp");
   }
   catch (e)
   {
    return false;
   }
  }
 }
 quer.onreadystatechange = function(){
  if (quer.readyState == 4)//Good to go.
  {
   var resp = quer.responseText;
   alert(resp);
  }
 }
 quer.open("POST", "(blanked URL for security reasons)", true);
 quer.send(null); 

Resp is always, and I mean ALWAYS blank. Can anyone offer any help?


THe AJAX JS is on a different website than the PHP

There is your problem. You can't do an XMLHttp request from a different domain.

You can read more about the same origin policy.


You cannot make AJAX requests to scripts that reside on other domains. It is a violation of the same origin policy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜