I am trying to scrap some elements data from a page using jquery and sending to a php file to save in database what i am doing is:
- I am creating two dimensional array and want to pass data to php file so I can run a foreach load to save in database:
Error: Now getting the message : SyntaxError: Unexpected token A in alert box which is alert(errorThrown);
my jquery code is:
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;
}
and i am trying to get it in php file as :
print_r($_POST) ;
please let me know in comments if you think question is not good or not explaining well.
Thanks.