I have some PHP code that posts data to an API, and compiles the POST information for curl as follows:
<?php
$post_data['field'] = 'fieldsValue';
$post_data['field2'] = 'field2sValue';
$post_data['parameters']['limit'] = '10';
$post_data['parameters']['offset'] = '10';
$post_data['parameters']['search'] = 'value';
?>
How would one achieve the same nested parameters to accommodate ['parameters']['limit'] and ['parameters']['offset'] values in a javascript post using XMLHttpRequest?
Code so far:
<script>
function fieldSearch(query){
var xhttp = new XMLHttpRequest();
var postdata = "field=fieldsvalue&field2=field2sValue";
xhttp.open("POST", "app.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.setRequestHeader("Content-length", postdata.length);
xhttp.send(postdata);
}
</script>
$_POST['parameters']['limit']?