AngularJSのhttpメソッドをつかってPOSTでRailsのAPIサーバにデータを送り登録しています。
ですが、以下のようなエラーが出ます。
angular.js:13920 SyntaxError: Unexpected token c in JSON at position 0
var host = 'http://localhost:3000'; $scope.createPost = function() { $http({ method: 'POST', url: host + '/api/posts' }).success(function(data) { console.log("success"); }).error(function() { console.log("fail"); }); }
いろいろ簡略化しています。
処理自体はerror となり consoleにfailと表示されるのですが、なぜかデータが保存されます。
このエラーの原因もわかりませんし、なぜerrorとなっても保存されるのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/08/29 10:18 編集