私はイオンフレームワークでアプリケーションを作成していますが、httpをバックエンドのREST API(ボタンがクリックされるたびにリクエストされます) JSON形式のレスポンスJSONのhttpポストレスポンス受信時にイオン解析でエラーを受け取るとき
ボタン:バックエンドは、バックアプリのイオンに対する応答を与える私は、このエラーが発生します
$scope.request = function() {
var requestURL = API_URL + "request";
$http.post(requestURL, "userID=TJones92&cat=Mobile", { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(
function (res) {
$scope.response = res.data
})
:ここ
<div class="RequestButton">
<div class="button button-assertive" ng-click="request()">
<a class="button">Request</a>
</div>
</div>
がバックエンドへの呼び出しを行うアプリからのコードですウェブページのコンソールで:
Error: JSON.parse: expected property name or '}' at line 1 column 5 of the JSON data
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:14543:9
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:22560:16
transformData/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:22651:12
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:13648:11
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:22650:3
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:23406:23
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:27879:28
scheduleProcessQueue/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:27895:27
$RootScopeProvider/this.$get</[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:29158:16
$RootScopeProvider/this.$get</[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:28969:15
$RootScopeProvider/this.$get</[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:29263:13
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:23676:36
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:23848:7
[email protected]://localhost:8100/lib/ionic/js/ionic.bundle.js:23789:9
なぜこのエラーが発生しているのかわからない私はJSONレスポンスに対して何もしません。私がこれを間違って実行しているかどうかわかりません
サーバからの応答が本当にjsonではないように見えます。あなたもあなたの回答を投稿できますか? – Srijith
実際に返された情報を確認するには、ブラウザのdevツールネットワークで実際のリクエストを調べます。あなたのPHP出力コードを表示する – charlietfl
あなたのサーバーは間違った形式のjsonを送信していると思います。 – Gatsbill