jQuery/Ajax - How to generate a valid POST hash?


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var hash = new String();
  2.  
  3. $.each(elements, function(k) {
  4.  
  5. hash += this['id'] + 'weight: "' + k + '",\n';
  6. hash += this['id'] + 'children: "' + this['children'].toString() + '",\n';
  7.  
  8. });
  9.  
  10. "if I print hash I get:"
  11.  
  12. node1weight: "0",
  13. node1children: "node3,node4",
  14. node2weight: "1",
  15. node2children: "",
  16. node5weight: "2",
  17. node5children: "",
  18.  
  19.  
  20. "but the $_POST array in my php script is empty when using the following line:"
  21.  
  22. $("#field1").load("/nodes/sort", hash);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.