看板 Ajax 關於我們 聯絡資訊
http://api.jquery.com/jQuery.parseJSON/ 我根據這個網站教學 但是網頁回傳找不到 jQuery.parseJSON 這個function 我是從 A.php送到-->B.php再傳回-->A.php 我有看回傳值,回傳的很正確 但是無法解析json 請問這如何解決?? A.php <script type="text/javascript" src="jquery.js"></script> <script type='text/javascript'> abc(); function abc(){ createRequest(); var url='B.php'; post_str='aaa=1'; request.onreadystatechange=abc_res; request.open('POST',url,true); request.setRequestHeader("Content-Type","application/x-www -form-urlencoded;charset=UTF-8"); request.send(post_str); } function abc_res(){ if(request.readyState==4){ if(request.status==200){ 這行出錯==> var orgData=jQuery.parseJSON(request.responseText); .... } } } </script> B.php 程式如下 if(isset($_POST['aaa'])){ $query="SELECT * FROM a_table"; $res=$db->query($query); $his_data=array(); while($data=$res->fetch()){ array_push($his_data,$data); } echo json_encode($his_data); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.124.6.193
s25g5d4:你有check你的jQuery版本嗎 12/17 21:01
我是下載最新版1.4.4 ※ 編輯: tabear 來自: 59.124.6.193 (12/17 21:22)
mesak:$.post('b.php',{'a':1},function(r){ 12/17 23:34
mesak:var b = $.parseJSON(r); 12/17 23:35
mesak:}) 12/17 23:35
mesak:幫你簡化一下 12/17 23:35