i try to send some data to my php file from ajax , but i could not succeed. This is my ajax file,
var artistIds = new Array();
$(".p16 input:checked").each(function(){
artistIds.push($(this).attr('id'));
});
$.post('/json/crewonly/deleteDataAjax2',artistIds,function(response){
if(response == 'ok')
alert('error');
else
alert('nop');
})
and in PHP side i use this code
extract($_POST);
if(isset($artistIds))
$this->sendJSONResponse('ok');
else
$this->sendJSONResponse('error');
$artistIds always come with null why why why
finally i came to this but also does not work
var artistIds = new Array();
$(".p16 input:checked").each(function(){
artistIds.push($(this).attr('id'));
});
$.post('/json/crewonly/deleteDataAjax2', { artistIds: artistIds },function(response){
if(response == 'ok')
alert('dolu');
elseif (response == 'error')
alert('bos');
});*
You can't post an array without serializing into name-value pairs.
You'll need to pass an object to associate values with names.
var data = {
artistIds: artistIds //Here, the property name is "artistIds", which is going to be the name of your PHP variable. Your JS variable is also called that.
};
$.post('/json/crewonly/deleteDataAjax2',data,function(response){
//...
Do your $.post like this:
$.post('/json/crewonly/deleteDataAjax2', { artistIds: artistIds }, ...);