I have a jQuery-function that passes a list of objects to my server via AJAX:
var pList = $(".post:not(#postF)").map(function() {
return this.id;
});
$.ajax({
type: "POST",
url: "refresh",
data: "pList="+pList,
...
on PHP-side, I need to check if a certain needle is in that array, I tried the following:
$pList = $_POST['pList'];
if(in_array('p82', $pList)){
error_log('as');
}
which does not work, although "p82" is in the array. Maybe the jQuery object is not a real array or not passed to PHP as an array? Thanks for any help.
var_dump($_POST['pList']);
to your PHP script and then have a look what it outputs via developers.google.com/chrome-developer-tools/docs/network or Firebug. And yes, you need to serialize your list. – MartyIX May 1 '13 at 9:33