2016-09-27 13 views
0

私はWebアプリケーションとGraylogサーバを持っています。 Graylogサーバーにajaxメッセージを送信したいと思います。それらが提供する唯一の例は次のとおりです。Graylog2へのJQueryのajaxコールが機能しない

curl -XPOST http://graylog.example.org:12202/gelf -p0 -d '{"short_message":"Hello there", "host":"example.org", "facility":"test", "_foo":"bar"}' 

これはうまくいきます。しかし、私がこれをするとき:

message = '{"host":"hostname","short_message":"short message","full_message":"longer message","facility":"dev"}'; 
        console.log(message); 
        $.ajax({ 
          url: 'http://X.X.X.X:12201/gelf', 
          method: 'POST', 
          data: JSON.stringify(message), 
          success: function(result, textStatus, jqXHR){ 
            console.log("SF Log posted with result: " + result); 
            if ($.isFunction(settings.callback)) { 
              settings.callback.call(this); 
            } 
          }, 
          error: function(jqXHR, textStatus, errorThrown){ 
            console.log("SF Log encountered error: " + errorThrown); 
          }, 
          complete: function(){ 
            console.log('on complete: ' , this.data); 
          } 
        }); 

メッセージはGraylogで受信されますが、処理を拒否します。ジャーナルに座っているだけです。

これは私が書いているプラ​​グインの私の現在の設定で、別の領域にログインすることができます。私はcrossDomainをtrueに設定していましたが、$ .postだけを使ってみましたが、私の環境は何らかの理由で私を許可しません。他に何ができるの?

答えて

0

もちろん、10分後に問題が見つかりました。 JSON.stringifyを取り除く。

関連する問題