teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

success/errorの書き方がjQuery1\.8以降非推奨だったらしいので\(http://www\.tohoho-web\.com/js/jquery/ajax\.htm\)done/failに変更

2016/05/03 12:13

投稿

yohira0616
yohira0616

スコア257

title CHANGED
File without changes
body CHANGED
@@ -35,10 +35,10 @@
35
35
  data: JSON.stringify(param),
36
36
  contentType: 'application/json',
37
37
  dataType: 'JSON'
38
- }).success(function (response) {
38
+ }).done(function (response) {
39
39
  console.log('post done');
40
40
  console.log(response);
41
- }).error(function(error){
41
+ }).fail(function(error){
42
42
  console.log('post error');
43
43
  console.log(error);
44
44
  });
@@ -86,10 +86,10 @@
86
86
  data: null,
87
87
  contentType: 'application/json',
88
88
  dataType: 'JSON'
89
- }).success(function (response) {
89
+ }).done(function (response) {
90
90
  console.log('done!');
91
91
  console.log(response);
92
- }).error((error)=> {
92
+ }).fail((error)=> {
93
93
  console.log('error!');
94
94
  console.log(error);
95
95
  });
@@ -99,7 +99,7 @@
99
99
  ```
100
100
  結果:console.logに’done!’と表示される
101
101
 
102
- success/errorではなくthen/catchメソッドを使って実装しても効果なし(ステータスコード200でcatch側のメソッドが実行される)
102
+ done/failではなくthen/catchメソッドを使って実装しても効果なし(ステータスコード200でcatch側のメソッドが実行される)
103
103
 
104
104
  ###補足情報(言語/FW/ツール等のバージョンなど)
105
105