Ajax get serialize array values in php

i just want get the serialize array values. i dont print_r or something, i just want get the serialize array something “urun 1, urun 2” not like urun_id%5B%5D=%C3%BCr%C3%BCn+test+1&urun_id%5B%5D=%C3%BCr%C3%BCn+test+1 or array("value"=>"urun 1"). i tried many ways but it didnt work how i want. how i can get the values? thank you for help from now.

Html;

<form id="urunTeklifOlustur" >
<select name="urun_id[]" id="urun_id">
</select>
</form>

Ajax;

 $("#urunTeklifOlustur").submit(function(e) {
    e.preventDefault();

    $("#load").text("bekleyiniz...");
    $.ajax({
        url: "<?php echo base_url(); ?>index.php/yonetici/addUrunTeklifGiris",
        type:'post',     
  data : {urun_id :$( "#tablo #urun_id" ).serialize()},
        success: function(data){
        $("#load").hide();
        $(".sonuc").html("<b>Başarılı</b>! Kayıt başarılı bir şekilde gerçekleşti").show();
        setTimeout(function() {
        $(".sonuc").hide();
        $("#load").show().html('<i class="fa fa-send"></i>  Gönder');
            $(".res").html(data);

        $( ".gui-input" ).val("");
   }, 800);
    }
    });
}); 

Php;

   public function addUrunTeklifGiris(){

1.way;

  $urun_id =  $this->input->post("urun_id");
 echo array("value"=>$urun_id);

2.way;
for($i = 0; $i<count($urun_id); $i++){

echo $urun_id[$i];

} 

3.way

foreach($urun_id $key=>$val){

echo $key . "->" . $val;

}
 } 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s