I have a table with the first column made up of checkboxes. I want to collect the values of the checked rows with jquery and transmit these to a aphp function for processing .
So far I have:
var searchIDs = $('input:checked').map(function(){
return $(this).val();
});
which returns an object containing the checked values.
I can get a list of these using :
searchIDs.get()
of the form :
1,2,3 etc
Now I need to send this to php. I tried:
$.ajax({
type: "POST",
url: "update/updateR",
contentType: 'application/json',
data: searchIDs.get() ,
contentType: 'application/json',
dataType: 'json',
success: function(){
alert("OK");
}
});
However in my php function which consists of:
$json = $_POST['json'];
var_dump($json);
exit;
I get the following error:
<p>Message: Undefined index: json</p>
What am I doing wrong?
addendum:
I changed the ajax to
$.ajax({
type: "POST",
url: "update/updateR",
contentType: 'application/json',
data:{ searchIDs : searchIDs.get() },
dataType: 'json',
success: function(){
alert("OK");
}
});
but I'm getting the same error and the var_dump in the php method gives NULL