0
我想放棄使用jQuery和發送到PHP文件從網頁數據的一些元素數據庫來保存我在做什麼是:運行jQuery的阿賈克斯多diemnstion陣列不形
- 我創建二維陣列和要傳遞數據到PHP文件,所以我可以運行一個foreach負載在數據庫來保存:
錯誤:現在獲取消息:語法錯誤:在警報盒意外標記A,其是警報(errorThrown) ;
我jQuery代碼是:
function scrape() {
var info = new Array();
$("div.clip").each(function (index) {
info[index] = {};
info[index]['name'] = $(this).find(".fn").text();
info[index]['rating'] = $(this).find("span.tinyPush").text();
info[index]['review'] = $(this).find("p.description").text();
});
console.log(info);
$.ajax({
type: "POST",
url: "save_scrap.php",
data: {info: info},
dataType: "json",
beforeSend: function() {
// Do something before sending request to server
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (data) {
console.log(data);
$("#div1").html(data);
alert('success!');
}
});
return false;
}
,我試圖讓它在PHP文件:
print_r($_POST) ;
請讓我知道在評論,如果你認爲問題不在於好不好解釋得很好。
謝謝。
你應該開始說什麼不工作 – 2014-10-17 15:47:49
哦對不起。我不能在php文件中只顯示任何內容,所以我可以做任何查詢 – MWT 2014-10-17 15:48:56
你是否從'console.log'中獲取任何東西?否則,可能是因爲'var info = new Array();'在'.each'範圍內聲明。在'.each'之前移動這個聲明,你應該很好。 – 2014-10-17 15:50:27