javascript - jQuery ajax doesn't send array -


i'm trying send data in array via ajax save database, build array way:

$( "#saveordering" ).button().click(function( event ) {             event.preventdefault();              var data = document.getelementbyid('tabs');             var categories = data.getelementsbytagname("div");             var categoryarray = new array();              (var i=0; < categories.length; i++) { //loop door de categoriƫen                 var category = categories[i];                 var categoryid = category.getattribute('id');                  categoryarray[i] = new array();                  categoryarray[i]['id'] = categoryid;                 categoryarray[i]['forums'] = new array();                  var forums = category.getelementsbytagname("li");                 (var j=0; j < forums.length; j++) { //loop door de forums                     var forum = forums[j];                     var forumid = forum.getattribute('id');                     categoryarray[i]['forums'][j] = new array();                     categoryarray[i]['forums'][j]['id'] = forumid;                 }             }             $.ajax({                 type: 'post',                 url: "ajax/updateboardorder.php",                 datatype: 'json',                 data: {ldelim}"categories" : categoryarray{rdelim} ,                 success: function(data) {                 }             });          }); 

but nothing send, when var_dump($_post) in php i'm getting:

array (size=0) empty

what doing wrong?

look @ code

categoryarray[i] = new array(); categoryarray[i]['id'] = categoryid; categoryarray[i]['forums'**strong text** 

um, not "array", making associative array

categoryarray[i] = {}; categoryarray[i]['id'] = categoryid; categoryarray[i]['forums'] = {}; 

or

categoryarray[i] = {     "id" : categoryid,     "forums" : {} }; 

you want object. same later in code forums.


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 -