jquery來處理ajax,用到了json。但是很詫異,jquery的ajax回調時一直調用了error函數(一直提示parsererror異常),success函數一次沒執行過
1 $.ajax({ 2 type:'POST', 3 url:'/go.php?p=chat.chatCenter&a=send', 4 dataType:'json', 5 data:'style='+Tstyle+'&content='+content, 6 success:function(data){$.chatCenter.sendEnd(data);}, 7 error:function(data,t){alert("系統異常["+t+"]");$.chatCenter.sendEnd();} 8 });
最后發現是json的數據格式出錯了!數據格式必須為雙引號