javascript - 使用http服务时访问xampp本地主机文件

标签 javascript php angularjs localhost httpservice

我找不到关于如何访问我自己的本地主机作为开发环境来测试 http 服务的明确答案。 到目前为止我已经尝试做 http://localhost:8080/Folder/this.php它去了 www.localhost.com ???我检查过配置文件中的访问端口为80。

这是我想要实现的代码片段

function TMSSvc($http,$rootScope){
    this.loadBlogs= function(){
        $http.get("http://localhost:8080/webService/getBlogs.php").success(function(result){
              $rootScope.$broadcast("TMSApp.blogs",result);
          });
    }
}

你能帮我吗?我是这方面的初学者。 谢谢您

最佳答案

如果您使用的是 Windows,则需要转到该文件:

C:\Windows\System32\drivers\etc\hosts

如果您使用的是 Linux 或 Mac:

/etc/hosts (i.e. sudo nano /etc/hosts)

然后取消注释该行:

#   127.0.0.1       localhost

所以它是这样的:

    127.0.0.1       localhost

然后您应该能够使用 localhost 访问本地服务器。

关于javascript - 使用http服务时访问xampp本地主机文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33644311/

相关文章:

javascript - 如何在 openLayer map 中加载本地 gpx 文件?

php - 如何在简单的登录系统上添加password_hash函数?

php - 如何将值传递给模态?

javascript - AngularJS 和 Angular Material 性能问题

javascript - 上传函数没有被 ng-file-select 调用

javascript - 字符串和任何数字的正则表达式

javascript - 使用 signalR 将数组传递给服务器

javascript - 从三个日期时间变量中查找最大日期

php - 将 cakephp 2.6 升级到 2.8 以使用 php 7

javascript - 在angular js中从web api下载csv文件