I have reached here after doing a lot research, Its simple task creating a lot heck I am unable to pass javascript array to php some links which i viewed 1, 2, 3
I have created javascript object
obj={};
//for each loop of table to create the key - value pair of object
obj[$(r).find('td:eq(2)').html()]=i+1;
//end of for each loop
//now I console the object
which shows in console like this
after doing this var myJSON =JSON.stringify(obj);
I get the result as empty json string,I want to pass this sting to php via ajax, Not able to figure out why I have tried creating array as well, need help
fiddle link here here is full code
$fields_table=$('#datatableRank');
obj={};
table.on( 'row-reorder', function ( e, diff, edit ) {
setTimeout(function() {
// Update the field order values
$fields_table.find('tbody').find('tr').each(function(i,r){
//var element = {};
//element.id = $(r).find('td:eq(2)').html();
//element.quantity = i+1;
//obj.push(i+1);
//obj1.push($(r).find('td:eq(2)').html());
$(r).find('td:eq(0)').html(i+1);
obj[$(r).find('td:eq(2)').html()]=i+1;
});
}, 10); // Give it time to load in the DOM
console.log(obj);
var myJSON =JSON.stringify(obj);
console.log(myJSON);
}`