php - push javascript array through jquery -


i need pass in javascript array jquery code returning [object object]

$( "#enviar" ).click(function() {         var data = {};         var = 0;         var u = -1;          $.each($('.ui'), function() {              data[i] = this.value;              i++;         });          console.log(data);          $.ajax({                  type: "post",                 url: "send_car.php",                 data: "photo="+data+"&u="+u,                 success: function(data){                  }//end success               })//end ajax submit*/    }); 

console log showing array

object {0="d-170", 1="d-171"} 

but data being pass [object object]

ui class hidden input same name , different values.

i have read various post , tried serialize same results.

you're concatenating object , string, jquery supports passing in arrays , objects directly, use that

$.ajax({        type: "post",       url: "send_car.php",       data: {            photo : data,            u     : u       },       success: function(data){        } }); 

what you're doing is

var obj  = {key : "value"};  var data = "test" + obj; 

and when add object string, both become strings, , string representation of object [object, object].


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -