我能夠使用 ajax 從 php 文件中獲取 JSON 數(shù)據(jù)。我 console.logged 它,數(shù)據(jù)以 JSON 格式存在。但是,當(dāng)我嘗試引用特定參數(shù)時,它并沒有出現(xiàn),而是說, "VM160:1 Uncaught SyntaxError: Unexpected token { in JSON at position 79 at JSON.parse (<anonymous>) at Object.success (debate.php:202) at c (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at l (jquery.min.js:2) at XMLHttpRequest.<anonymous> (jquery.min.js:2) ".就 PHP 而言,我查詢了數(shù)據(jù)庫并創(chuàng)建了一個 $data 數(shù)組,然后對其進行編碼:$data['title'] = $row['title'];$data['first'] = $row['first_option'];$data['second'] = $row['second_option'];$data['id'] = $row['idUsers'];$data['uid'] = $row['uidUsers'];echo json_encode($data);在引用具有 JSON 數(shù)據(jù)的變量之前,我已經(jīng)嘗試使用 JSON.parse。
收到 JSON 但無法寫入頁面
有只小跳蛙
2021-08-20 10:08:25