This's my code it's success but when but I can't the return data from ajax in the same page.
the mechanism is the user click the dropbox button and when he selects it returns dropbox_links
and then insert dropbox_links
in database using add_post_meta
The Insert should be on the spot becuase the dropbox button click is the only trigger
$.ajax({
type: "POST",
data: {
req: JSON.stringify(dropbox_links)
},
cache: false,
success: function(responseData) {
// consider using console.log for these kind of things.
console.log("Data recived: " + responseData);
console.log(dropbox_links);
},
error: function(msg) {
console.log("not sure what to ask for here to check issue" + msg);
}
});
This's the php code but I don't catch or print any data so should I re-run the whole php script to see if it returns any data?
function printdata()
{
$data = $_POST["req"];
$data = json_decode($data, true);
print_r($data);
}
if (isset($POST["req"])) {
printdata();
} else {;
}