user1277467
user1277467

Reputation: 199

Ajax sending data to php

i try to send data to php with php.

var data = {
        'artistId[]' : []
    };    
    $(".p16 input:checked").each(function(){
        data['artistId[]'].push($(this).val());
    }); 


    $.post('/json/crewonly/deleteDataAjax2',data,function(response){
        alert("silindi");
    })

This is my code and i need to handle data variable in php side.

i try this

 $ids = $_POST['data'];

   if($ids == null)
       echo "null";
   else
       echo "not null";

but it prints "null". What might be the reason ?

I think below code does not send the checkbox array

  {if $key lt $castCount-1}
                <li class="p16 pd_5 border_b"><a class="bordo" href="{$mCast.url}">{$mCast.nameSurname}</a> <a href="{$mCast.characterUrl}" class="sag bordo">{$mCast.characterName}</a>
                {else}

                <li class="p16 pd_5"><a class="bordo" href="{$mCast.url}">{$mCast.nameSurname}</a> <a class="sag bordo" href="{$mCast.characterUrl}">{$mCast.characterName}</a>
                {/if}
               <input align="right" type=checkbox name="checkArtist[]"></li>
                {/foreach}
                <a style="float: right" href='javascript:void(null);' onclick="deleteData2();" >
                    <input type="button" name="checkArtistButton" value="Sil" id=value></a>

Upvotes: 1

Views: 197

Answers (1)

Miraage
Miraage

Reputation: 3464

$.post('/json/crewonly/deleteDataAjax2', {data:data}, function(response){
    alert('silindi');
});

this?

Upvotes: 2

Related Questions