Javascript AngularJS http get请求挂起

Javascript AngularJS http get请求挂起,javascript,angularjs,http,Javascript,Angularjs,Http,我正在运行以下代码 $http.get(cmdUrl, {async: true, cache: false}). success(function(data, status, headers, config) { $scope.logText = data; }). error(function(data, status, headers, config) { $scop

我正在运行以下代码

        $http.get(cmdUrl, {async: true, cache: false}).
          success(function(data, status, headers, config) {
            $scope.logText = data;
          }).
          error(function(data, status, headers, config) {
            $scope.logText = "An error occurred";
          });
当我运行我的应用程序时,我有一个按钮,单击该按钮将调用上面的get()方法。第一次单击按钮时,成功回调将成功运行。我的问题是,当我第二次点击按钮时,我没有得到任何回应。 我使用(Chrome)调试器逐步检查了代码,发现在第一次调用后,我得到了200的状态代码,但在随后的每次调用中,请求都处于挂起状态。此外,在单步执行代码时,对于每个后续请求,都不会执行成功或错误回调。另外,过了一会儿,我猜挂起的请求超时了,在控制台中,我看到每个挂起的请求都有一个ERR_CONNECTION_被拒绝

我想知道为什么后续get被置于挂起状态,以及如何让它们执行到完成

Thanx

这是服务器端使用NodeJS编写的代码

   app.get('/cmdURL', function(req, resp, next) {
       var intercept = require('intercept-stdout');
       var deasync = require('deasync');

       var captured_text = "";
       var unhook_intercept = intercept(function(txt) {
           captured_text += txt;
       });
       var logs = [];                                              
       var responseText = "";                                      
       var done = false;                                           

       var hook_stream = function(_stream, fn) {
           // Reference default write method
           var old_write = _stream.write;
           // _stream now write with our shiny function
           _stream.write = fn;

           return function() {
               // Reset to the default write method
               _stream.write = old_write;
           };
       };

       // Set hook for standard output
       var unhook_stdout = hook_stream(process.stdout, function(string, encoding, fd) {
           if (string.includes("-- end of response --")) done = true;             
           logs.push(string);                                      
       });

       var command = req.query.text;                               
       if (command) {
           var valid = issueCommand(command);

           if (valid) {
               while(!done) {
                   deasync.sleep(200);
               }
               unhook_stdout();

               console.log('Not hooked anymore.');

               // Now do what you want with logs stored by the hook
               logs.forEach(function(_log) {
                   responseText += _log;
               });
           }
           else {
               unhook_stdout();
               responseText += "Unrecognized command";
           }

           resp.status(200).send(responseText);
       }
       else {
           console.log('No command was specified.');
           resp.status(404).send('No command was specified.');
       }
   });

   function issueCommand(cmd) { 
      // Issue an asynchronous cmd
   }

您使用的是哪个版本的angularjs?”success已经过时,它与then一起工作抱歉,我的示例正在使用AngularJS v1.5.8运行,可能是重复的,您可以向我们展示更多代码吗。此方法是服务的一部分吗?阅读后,这似乎与Chrome开发者窗口问题不同。顺便说一句,Firefox中也存在这种情况。上述解决方案产生的结果与我最初的实现相同。cmdUrl上返回响应数据的函数有时可能是异步函数。