0

Elastic Search (ES) にクエリを実行し、結果をファイルに保存するページを作成します。JQuery.post を使用してクエリを送信しようとすると、エラー {"error": "Please use POST request"} が表示されます

    $(document).ready(function(){

        alert("ready!");

        $("#go").click(function(event) {

            alert("go!");

            /* get some values from elements on the page: */
            url=$("#host").val();
            alert(url);

            q=$("#q").val();
            alert(q);

            var posting = $.post( url, { data: q } );

            /* Put the results in a div */
            posting.done(function( data ) {
                alert(data);
                // var content = $( data ).find( '#content' );
                // $( "#result" ).empty().append( content );

                alert("done!");
            });

        });
    });
4

1 に答える 1

0

これを試して、

$.post("test.php", { name: "John", time: "2pm" })
 .done(function(data) {
  alert("Data Loaded: " + data);
 });

また、$.post を返す xhr ステータスを確認します。また、コードに失敗コールバックを含めます。

.fail(function() { alert("error"); })

完全なリファレンスはこちら

于 2013-05-24T17:50:28.773 に答える