亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

出現錯誤:Uncaught SyntaxError: JSON.parse: JSON 數據第 3

出現錯誤:Uncaught SyntaxError: JSON.parse: JSON 數據第 3

至尊寶的傳說 2023-11-02 21:05:01
對于以下代碼獲取輸出$response=array();    $response['wheel_deg_end'] = (360*(ceil($wheel->wheel_spin_time/3))) + (360 - (($wheel_slice_number * 30) - 30)) + rand(-5,5);$response['wheel_time_end'] = $wheel->wheel_spin_time * 1000;$response['success'] = true;                    $ab = json_encode($response,JSON_NUMERIC_CHECK);echo $ab;輸出:"{"wheel_deg_end":1743,"wheel_time_end":10000,"success":true}"Json 解析錯誤:jQuery.ajax({    url: couponspining_ajaxurl,    type: 'POST',    data: {        action: 'couponspining_wheel_run',        form_data: form_data,        preview_key: this.preview_key    },    context: this,}).done(function(json){    this.submit_form_done(jQuery.parseJSON(json));});未捕獲的語法錯誤:JSON.parse:JSON數據submit_form的第3行第1列出現意外字符 http://localhost/shopify-php-app/src/public/assets/js/couponspining1.js:210
查看完整描述

3 回答

?
慕萊塢森

TA貢獻1810條經驗 獲得超4個贊

只需將解析 json 行從

this.submit_form_done(jQuery.parseJSON(json));

this.submit_form_done(json);

因為如果 AJAX 調用的配置具有 dataType: json,您將獲得一個 JavaScript 對象,因此不再需要使用 JSON.parse()。


查看完整回答
反對 回復 2023-11-02
?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

"{"wheel_deg_end":1743,"wheel_time_end":10000,"success":true}"不是有效的 json 字符串。

哪個應該是{"wheel_deg_end":1743,"wheel_time_end":10000,"success":true}


查看完整回答
反對 回復 2023-11-02
?
料青山看我應如是

TA貢獻1772條經驗 獲得超8個贊

將內容類型設置為 json:


jQuery.ajax({

  url: couponspining_ajaxurl,

  type: "POST",

  contentType: "application/json",

  data: {

    action: "couponspining_wheel_run",

    form_data: form_data,

    preview_key: this.preview_key

  },

  context: this

}).done(function(json) {

  this.submit_form_done(jQuery.parseJSON(json));

});


查看完整回答
反對 回復 2023-11-02
  • 3 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號