var jj = []; $('.pageblock').each(function(i,elem) { jj[i] = { name: $(elem).find('.name').val(), age: $(elem).find('.age').val() } }); myJson = JSON.stringify(jj); 

I collect all downloaded names and ages from the screen, collect them in json and send them to the server:

 $.ajax ({ type: "POST", url: 'kernel.php?cmd=savearticle', dataType: 'json', async: false, data: myJson, success: function (data) { console.log(data) } }) 

in php script just trying to return the received

 print_r( $_POST['data'] ); 

What I do wrong does not return anything. Who will tell?

  • Well, at least it is desirable to see what is happening in the browser console, what errors are there. - Sergey Glazirin
  • [Deprecation] It’s a demanding XML experience. For more help, check xhr.spec.whatwg.org . send @ jquery.min.js: 4 ajax @ jquery.min.js: 4 saveArticle @? inc = pageeditor & type = article & ident = about: 247 onclick @? inc = pageeditor & type = article & ident = about: 80 - Anton Mescheryakov

1 answer 1

The data to be sent must have an element with the "data" key:

 // async: false, data: { data: jj }, 
  • [Deprecation] It’s a demanding XML experience. - Anton Mescheryakov
  • swears at jquery - Anton Mescheryakov