如何设置我的wamp以允许来自其他域的请求

How can i setup my wamp to allow request from other domains

本文关键字:其他 请求 何设置 设置 wamp 我的      更新时间:2023-09-26

我使用applicationcraft作为前端(在applicationcraft服务器上),cakephp作为后端(安装在localhost-wamp服务器中)。

下面的代码是我使用ajax从applicationcraft连接到localhost:的部分

var params = {name : "madhan",id: 1}; 
app.httpRequest("http://client1.localhost/ezfit-be/users/index",        
      "POST",function(data, error, httpResponse){    
       debugger;
        if (error === false){
          //app.setValue("testlabel", data.results[0].formatted_address);
          alert(data);
      } else {
          alert("Cannot locate it");
     }
    }, params , "json" );
 }
}

然而,当我运行它时,它显示无法连接到地址。我认为我的本地主机不允许来自另一个域的请求。

我尝试设置一个虚拟主机(client1.localhost),但它仍然给了我相同的错误

如何设置我的wamp以允许来自其他域的请求?

如果运行Ajax operationdomain与"Ajax正在访问"的domain不同,则这是不可能的。

即使指向的域是子域。

请参阅本文和此处,其中提供了一些其他选项。