0

実行しようとしている次のコードがあります

   $.ajax({
      cache: false,
      url: './animationPlay.php',
      data: 'animation='+text,
      type: 'POST',
      datatype: 'text',
      success: function(data) { alert("succsess") },
      error: function(ts) { alert('error:'+ts.responseText) }
   });

ajaxクエリ投稿エラーをキャッチする方法を見てきましたか? jQuery $.get または $.post を使用してページ読み込みエラー (例: 404) をキャッチしますが、私のコードでは機能しません。単純に「エラー」に設定されています。問題の詳細を確認するにはどうすればよいですか?

前もって感謝します。

編集:試しました

error: function(xhr, textStatus, error){
  console.log(xhr.statusText);
  console.log(textStatus);
  console.log(error);
}

コンソールにエラー、エラー、空の文字列が表示されました。どういう意味ですか?

4

4 に答える 4

-1

これを試して:

$.ajax({
        cache: false,
        url: 'animationPlay.php',
        data:  text,
        type: 'POST',
        dataType: 'text',       //<== see, in your question's code you have small 't'
        success: function(data) { alert("succsess") },
        error: function(){
            alert('error');
        }
于 2013-04-15T13:44:51.413 に答える
-1
$.ajax({
      cache: false,
      url: './animationPlay.php',
      data: 'animation='+text,
      type: 'POST',
      dataType: 'text',
      success: function(data) { alert("succsess") },
      error: function(ts) { alert('error:'+ts.responseText) }
      contentType:'SET THE CONTENT TYPE'
   });

URL の存在を確認する

于 2013-04-15T13:28:02.290 に答える
-1

投稿データをオブジェクトとして送信してみてください...

$.ajax({
    cache: false,
    url: './animationPlay.php',
    data: {
        animation: text
    },
    type: 'POST',
    success: function(data) { alert("succsess") },
    error: function(ts) { alert('error:'+ts.responseText) }
});
于 2013-04-15T13:24:04.883 に答える