我的AJAX腳本都運行完美,並且成功功能正在工作,腳本仍然遇到錯誤消息。我確定問題是parseerror。我沒有確定的是爲什麼會發生這種情況,以及如何阻止它。JQuery AJAX莫名的解析錯誤
AJAX
var dataString = 'title=' + title + '&price=' + price + '&duration=' + duration + '&dives=' + dives + '&hire=' + hire + '&date=' + date + '¤cy=' + currency + '&cost=' + cost + '&supplier=' + supplier;
$.ajax({
type: 'POST',
url: '<?php echo $thisposturl?>?catadd',
data: dataString,
beforeSend: function() {
$('#loadwheel-new').html('<img id="BKloader" src="http://www.divethegap.com/update/z-images/structure/icons/ajax-loader.gif" alt="" width="30" height="30"/>');
},
error: function() {
$('#loadwheel-new').html('lkk');
},
dataType:'json',
success: function(data) {
$('#CollapsiblePanel' + data.CATid).load('<?php echo $thisposturl?> #' + data.CATid);
;
} });
PHP
$title = $_POST['title'];
$CATid = $the_post_id;
$date = get_the_time('Y-m-d');
$price = $_POST['price'];
$duration = $_POST['duration'];
$dives = $_POST['dives'];
$hire = $_POST['hire'];
$currency = $_POST['currency'];
$cost = $_POST['cost'];
$supplier = $_POST['supplier'];
echo json_encode(array('title'=>$title, 'CATid'=>$CATid, 'date'=>$date, 'price'=>$price, 'duration'=>$duration, 'dives'=>$dives, 'hire'=>$hire, 'currency'=>$currency, 'cost'=>$cost, 'supplier'=>$supplier));
並在服務器端或客戶端上出現解析錯誤? – 2011-03-16 14:21:53
嚴謹的一面。這與JSON有關我認爲 – 2011-03-16 14:25:31
您從服務器接收到的結果是什麼?你可以複製並粘貼使用螢火蟲。您應該能夠查看從服務器收到的響應。 – 2011-03-16 14:26:29