I can successfully post an array to PHP using Ajax Post but I want to extend this functionality to post an array of objects instead an array of values..im struggling to find clear examples of how to do this.
Here is how I am posting the array of values from the jQuery/Javascript client script:
var placesfortrip = {};
placesfortrip["place"+counter] = inputVal;
//note counter is an int that gets incremented for each value
//inputVal is a string with the new value to be added
var inputVal = jQuery("#edit-location").val();
jQuery.ajax({
url: "/createtrips/updateitin",
type: 'POST',
data: placesfortrip,
dataType: 'json'
});
Then at the PHP side I read the data like this:
$citynames = array();
foreach ($_POST as $key=>$value) {
$citynames[$key]= $value;
}
How can I modify the above to post an array of objects instead of values? Im particularly confused as to how to read the array of objects from the PHP side.