I am trying to send a json string and a variable thru ajax call and edit the query in php file,
My code looks like
queryData = {
"data": {
"data_string": {
"data": "oil",
"default_field": "Content"
}
}
};
from = 0;
$.ajax({
url: "/elasticsearch-head/lib/es/queryManipulate.php",
type: 'POST',
data: 'dataString',
datatype: 'json',
data: {
field: queryData,
start: this.from
},
success: function(data) {
Dumper.alert(data);
}
});
The PHP file looks like, Ive taken the two values in to variables, I wanna alter the json in php and return the value in the form {“from”: $from, “data”:{“data_string”:{“data”:”oil”,”default_field”:”Content”}}}
<?php
$testData=$_POST["field"];
$from=$_POST["start"];
?>
It should return the query 4 times and each time the value of $from should increment by 10
Is it possible to do that with ajax and php??
That would be my solution:
This is a recursive function calling itself four times.
EDIT: Or if I misread your question you could use a for-loop on the server side:
This would you let your data be processed four times.