php - Nothing's in $_POST. Is there something wrong with my code? -


i new javascript , php, , it's first time encounter , use json. think ajax request fine, so, $_post array empty.

here ajax call:

$( "#submit" ).click( function() {     var submit_basic = $.post( 'index.php/submit_data/pass_basic_data',                                 get_experience_data()                              );     submit_basic.done( function(data) {        alert(data);  // debugging purposes     }); }); 

and function takes data table:

function get_experience_data() {      var temp, data_exp = [];     $( "#exptable tbody tr" ).each( function() {          temp = {             company: $(this).find('td').eq(0).html(),             position: $(this).find('td').eq(1).html(),             datestart: $(this).find('td').eq(2).html(),             dateend: $(this).find('td').eq(3).html(),             description: $(this).find('td').eq(4).html()         };          data_exp = data_exp.concat(temp);       });       return data_exp; } 

and reference, destination controller function prints $_post array (by way using codeigniter):

public function pass_basic_data() {     var_dump($_post);         } 

can please pinpoint error i've made, since can't find it. lot!

update: getting message in particular:

array(1) {   ["undefined"] =>   string(0) "" } 

update:

thanks guys! solved it. made me dance around room. wrapped return value in {name : value} pair.

$( "#submit" ).click( function() {     var post_vars = get_experience_data();     var submit_basic = $.post( 'index.php/submit_data/pass_basic_data',                                 {object: post_vars}                              );     submit_basic.done( function(data) {         alert(data);  // debugging purposes     });  }); 

i suggest doing following start :

var submit_basic = $.post('index.php/submit_data/pass_basic_data', get_experience_data()); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -