Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Rest Api,正在尝试从Rest服务器获取数据_Javascript_Angularjs_Rest - Fatal编程技术网

Javascript Rest Api,正在尝试从Rest服务器获取数据

Javascript Rest Api,正在尝试从Rest服务器获取数据,javascript,angularjs,rest,Javascript,Angularjs,Rest,RESTAPI与邮递员和浏览器配合良好。 当通过jsp页面或html页面启动时,它将命中Rest方法,但响应为“0” JavaScript的Rest客户端 Respose为“0”,response.data为空 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title>

RESTAPI与邮递员和浏览器配合良好。 当通过jsp页面或html页面启动时,它将命中Rest方法,但响应为“0”

JavaScript的Rest客户端 Respose为“0”,response.data为空

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title></title>
        <script language="javascript">
        function getdetails() {
        var url = "http://localhost:9090/api/FGame/search1/";
        var client = new XMLHttpRequest();
        client.open("GET", url, true);
        client.send(null);
        if (client.status == 200)
        alert("The request succeeded!\n\nThe response representation was:\n\n" + client.responseText)
        else
        alert("The request did not succeed!\n\nThe response status was: " + client.status + " " + client.statusText + ".");
        alert(client.status);
        }
      </script>
      </head>
      <body>
       <h1>Call Employee Service </h1>
       <table>
       <tr>
           <td>Enter Employee ID :  </td>
           <td><input type="text" id="empno" size="10"/>  <input type="button" value="Get Details" onclick="getdetails()"/>
       </tr>
       <tr>
           <td>Enter Name :  </td>
           <td><input type="text" readonly="true" id="empname" size="20"/> </td>
       </tr>

       <tr>
           <td>Employee Age : </td>
           <td><input type="text" readonly="true" id="age" size="10"/> </td>
       </tr>
       </table>
      </body>
    </html>
//我用过角度也有同样的错误

<!doctype html>
    <html ng-app="demo">
    <head>
        <title>Hello AngularJS</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
        <script src="js/fGame.js"></script>
    </head>

    <body>
    <div ng-controller="Hello">
        <p>The ID is {{greeting.id}}</p>
        <p>The content is {{greeting.content}}</p>
    </div>
    </body>
    </html>
<!doctype html>
    <html ng-app="demo">
    <head>
        <title>Hello AngularJS</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
        <script src="js/fGame.js"></script>
    </head>

    <body>
    <div ng-controller="Hello">
        <p>The ID is {{greeting.id}}</p>
        <p>The content is {{greeting.content}}</p>
    </div>
    </body>
    </html>
angular.module('demo', [])
        .controller('Hello', function($scope, $http) {
            $http.get('http://localhost:9090/api/FGame/search1').
            then(function(response) {
                alert($http.status);
                $scope.greeting = response.data;
            });
        });[![Postman Snapshot][1]][1]


  [1]: https://i.stack.imgur.com/1EeXH.png