0

GET を使用した ajax 呼び出しを POST を使用したものに変換しようとしています。これは、 とうまく機能するものGETです。タイプを に変更してPOSTも機能しません。データ文字列の形式に問題がありますか?

 $.ajax({
    //type: "GET",  //works
    type: "POST",   // Does Not Work
    url: "/cgi-bin/my_perl.pl", // URL of the Perl script
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    //data format: "sid=" + sid + "&comments=" + comments,
    data: data_string,
    error: function(XMLHttpRequest, textStatus, errorThrown) { 
                            alert('AJAX Error');
    }, // error 
    // script call was successful 
    // data contains the JSON values returned by the Perl script 
    success: function(data){
            if(data.success) {
                    alert(data.success);
            }
            else if(data.error!=0) {
                    alert('We failed');
    } //else
    } // success
  }); // ajax
4

0 に答える 0