何在同一目录下发送文件的ajax请求

时间:2017-07-15 08:43:00

标签: javascript ajax

我想创建应用程序,当我输入url输入字段并获取有关请求的一些信息(页面标题和响应代码)。我阅读了很多主题,并了解到我无法向其他域发送请求,例如" google.com"和别的。然后我使用名为hi.php的html文件在目录中创建了文件,并发送如下命令:

<script>
           function getInformation() {

                 $.ajax({
                     type:"POST",
                     url:"http://localhost/test/hi.php",
                     success:function(data) {
                        alert(data);
                     }
                 });
             }
    </script>

但仍有错误

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

我该如何解决?我做错了什么?

0 个答案:

没有答案