0

次のAngular投稿リクエストをデバッグするためにChrome Devを使用しようとしています:

$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader)

右クリック/評価でステートメントを実行した後、保留状態の投稿がネットワーク パネルに表示されます。結果を取得するか、リクエストを「コミット」して、開発コンソールからこの「保留中」状態を簡単に終了するにはどうすればよいですか?

私はまだ JS コールバックにあまり慣れていません。いくつかのコードが必要です。ありがとう。

編集

コンソールから実行しようとしました:

$scope.$apply(function(){$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader).success(function(data){console.log("error "+data)}).error(function(data){console.log("error "+data)})})

戻り値: undefined

編集

返されるエラー メッセージは次のとおりです。JBoss Web/2.1.3.GA - Rapport d'erreur

エタット HTTP 400 -

親密な関係をタイプする

メッセージ

説明La requi te envoy par le client tait syntaxiquement illegale ().

JBoss Web/2.1.3.GA

編集私が解決しようとしている投稿は、HTTP 400 を生成します。結果は次のとおりです。

  • リクエスト URL: http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader リクエスト メソッド:POST ステータス コード:400 Mauvaise Requ?te リクエスト ヘッダービュー ソース Accept:application/json, text/plain, / Accept- Encoding:gzip,deflate,sdch Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 Connection:keep-alive Content-Length:5354 Content-Type:application/ json;charset=UTF-8 Cookie:JSESSIONID=285AF523EA18C0D7F9D581CDB2286C56 ホスト:picjboss.puma.lan:8880 オリジン: http://picjboss.puma.lan:8880 リファラー : http://picjboss.puma.lan:8880/fluxpousse/ 1200 updateDate: null Response Headersview source Connection:close Content-Length:996 Content-Type:text/html;charset=utf-8 Date:Fri, 08 Nov 2013 15:19:30 GMT Server:Apache-Coyote/1.1 X- Powered-By: サーブレット 2.5; JBoss-5.0/JBossWeb-2.1
4

1 に答える 1

1

各 $http リクエストには、次のような成功とエラーのコールバックが必要です。

$http({method: 'POST', url: '/someUrl'}).
success(function(data, status, headers, config) {
  // this callback will be called asynchronously
  // when the response is available
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});

これらのメソッド内では、Dev Tools でデバッグできます。

また、リクエストが保留中のままである場合は、サーバー側に問題がある可能性があります。

$http を利用可能にするブレークポイントがない場合 (たとえば、chrome devtools で Angular 1.2.6 を使用している場合) は、次を使用できます。

angular.element(document).injector()
 .get('$http')({method: 'POST', url: '/someUrl'})
    .success(function(data, status, headers, config) {
       console.log('$http-success:',arguments);
       debugger;
    })
    .error(function(data, status, headers, config) {
       console.log('$http-error:',arguments);
       debugger;
    });
于 2013-11-08T14:20:01.480 に答える