JSON encoded array comes out as null in PHP-Collection of common programming errors
I am making a small drag and drop app using jQuery UI’s Sortable feature. The jQuery works fine but when I try to encode the array of all of the lines in their order, the PHP script on the other side reads the array as NULL
and I cannot figure out why. Here’s everything in the order that they appear in my first script:
The HTML
REORDER
The JS
$(document).ready( function(){
var formOrder = document.getElementById('reorder');
formOrder.addEventListener('submit', function(){
var post_ids_field= document.getElementById('post_ids');
var ul_id = document.getElementById("photo-selector");
var post_ids = ul_id.getElementsByTagName("li");
post_ids_field.value = JSON.stringify(post_ids);
alert("check");
});
});
When clicking the “REORDER” button in the form up top it sends to orderupdate.php
which is as follows