Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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 如何在AngularJS中检查xmlhttpRequest_Javascript_Jquery_Angularjs_Xmlhttprequest - Fatal编程技术网

Javascript 如何在AngularJS中检查xmlhttpRequest

Javascript 如何在AngularJS中检查xmlhttpRequest,javascript,jquery,angularjs,xmlhttprequest,Javascript,Jquery,Angularjs,Xmlhttprequest,当我的状态为200时,如何检查XMLHttpRequest,为什么它不检查我的xhr angular.module("productManagement").controller('Employee', function ($scope, EmployeeService) { var xhr = new XMLHttpRequest(); $scope.GetdataBySubmit = function () { var GetData = EmployeeService.Ge

当我的状态为200时,如何检查
XMLHttpRequest
,为什么它不检查我的
xhr

angular.module("productManagement").controller('Employee', function ($scope, EmployeeService) {
  var xhr = new XMLHttpRequest();
  $scope.GetdataBySubmit = function () {
    var GetData = EmployeeService.GetEmployeeData();
    debugger;
    GetData.then(function(d) {
      if (xhr.status == "200") {
        $scope.Employee = d.data;
        $('#TadleData').show();
      } else {
        console.log("")
      }
    })
  }
})
这里我正在更新我的
GetEmployeeData
code

angular.module("productManagement").service("EmployeeService", function 
($http) {

  this.GetEmployeeData = function () {
    var x=$http({
        url: "http://localhost:9632/Api/Employee",
        method:"Get",
        data:JSON.stringify()
    })
    return x;
  }
})

无需定义和使用
xhr
变量

在使用
$http
并返回
Promise
时,请使用
success
回调处理程序
response
对象

GetData.then(function (response) {
    if (response.status == 200) {
        $scope.Employee = response.data;
        $('#TadleData').show();
    }
}, function (response) {
    console.log("Do something on error")
})

显示
GetEmployeeData
函数的代码,检查我认为是响应的
d
。所以只要
d.status
就行了你的
xhr
从来没有被使用过。。。?