Javascript AngularJS和$http.get请求不';行不通

Javascript AngularJS和$http.get请求不';行不通,javascript,html,angularjs,forms,Javascript,Html,Angularjs,Forms,我有一个奇怪的问题,我不知道是什么原因造成的 我制作了一个html页面,它包含在一个表单中。当您填写并按下“提交”按钮时,AngularJS会根据您在表单中所写的内容(搜索表单中指定位置附近的位置)向在线数据库执行查询,以获取特定值 该查询由一个HTTP GET请求进行,该请求返回您要查找的值 它是使用谷歌应用程序引擎开发的更复杂系统的一部分 当我在服务器上上传html页面,并通过浏览器访问它(键入页面的URL)时,它工作正常 但当我双击存储在电脑文件夹中的同一个html页面,然后在浏览器中打开

我有一个奇怪的问题,我不知道是什么原因造成的

我制作了一个html页面,它包含在一个表单中。当您填写并按下“提交”按钮时,AngularJS会根据您在表单中所写的内容(搜索表单中指定位置附近的位置)向在线数据库执行查询,以获取特定值

该查询由一个HTTP GET请求进行,该请求返回您要查找的值

它是使用谷歌应用程序引擎开发的更复杂系统的一部分

当我在服务器上上传html页面,并通过浏览器访问它(键入页面的URL)时,它工作正常

但当我双击存储在电脑文件夹中的同一个html页面,然后在浏览器中打开它,并尝试执行相同的操作时,它就不起作用了

我认为这是由非绝对URL和依赖项引起的,但URL是绝对的,没有依赖项(或者我没有找到它们)

你能告诉我怎么了吗?我想双击它,让它工作,因为这样,开发将比每次编写、上传和测试都要快

这是页面的html代码

<!doctype html>
<html ng-app="demoApp">

<head>
    <title>Search a location</title>
    <link rel="stylesheet" type="text/css" href="/css/helloworld.css">
</head>
<body>
<div ng-controller="HttpGetController"> 
    <br>Insert your data<br/>
<br>Name: <input type="text" name="Name" ng-model="Name"><br/>
<br>Category: <input type="text" name="Cat" ng-model="Cat"><br/>
<br>Latitude: <input type="number" step=any name="Lat" ng-model="Lat"/><br/>
<br>Longitude: <input type="number" step=any name="Lon" ng-model="Lon"/><br/>
<br>Distance:<br/>
<input type="radio" name="Ray" value="10" ng-model="Ray"> 10<br>
<input type="radio" name="Ray" value="20" ng-model="Ray"> 20<br>
<input type="radio" name="Ray" value="30" ng-model="Ray"> 30<br>
<input type="radio" name="Ray" value="40" ng-model="Ray"> 40<br>
<input type="radio" name="Ray" value="50" ng-model="Ray"> 50<br>
<button ng-click="SendData()">Submit</button>

<h3>Dati Page: {{ PostDataResponse }}</h3>
<h3>Dati Page2: {{ ResponseDetails }}</h3>
<p ng-bind-html="htmlAdText"></p>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
</script>  

<script>
var demoApp = angular.module("demoApp", []);



demoApp.controller("HttpGetController", function ($scope, $http, $sce) {
$scope.PostDataResponse = "null";
$scope.ResponseDetails="null";

$scope.SendData = function () {
        var URL = "https://xxxxxxxxx.appspot.com/xxxxxx?"+"Name="+$scope.Name+"&Cat="+$scope.Cat+"&Lat="+$scope.Lat+"&Lon="+$scope.Lon+"&Ray="+$scope.Ray;
        $scope.ResponseDetails=URL;
        $http.get(URL).success(function(data) {
              $scope.PostDataResponse = data;
              $scope.htmlAdText = $sce.trustAsHtml(data);
          });

       };

});


</script>        

</body>
</html>

搜索位置

插入您的数据

名称:

类别:

纬度:

经度:

距离:
10
20
30
40
50
提交 Dati页面:{{PostDataResponse} Dati第2页:{{ResponseDetails}

var demoApp=angular.module(“demoApp”,[]); 控制器(“HttpGetController”,函数($scope,$http,$sce){ $scope.PostDataResponse=“null”; $scope.ResponseDetails=“null”; $scope.SendData=函数(){ 变量URL=”https://xxxxxxxxx.appspot.com/xxxxxx?“+”Name=“++$scope.Name+”&Cat=“++$scope.Cat+”&Lat=“++$scope.Lat+”&Lon=“++$scope.Lon+”&Ray=“++$scope.Ray; $scope.ResponseDetails=URL; $http.get(URL).success(函数(数据){ $scope.PostDataResponse=数据; $scope.htmlAdText=$sce.trustAsHtml(数据); }); }; });
由于相同的源策略,您无法在不同的服务器上运行AJAX资源请求,除非服务器明确允许(通过在回复中设置标题)。双击计算机上的html将打开
文件://
环境中的页面,AJAX将停止工作。我知道了。谢谢