I am trying to edit a data query using php by passing it through javascript,
my ajax request looks like
var totalSearchResult=10;
$.ajax({
url:"php/queryManipulation.php",
type: 'POST',
data: { totalQuery : totalSearchResult, query : '{"data":{"match_all":{}}}'},
success: function(finalList)
{
alert(finalList);
}
});
my php code looks like
<?php
$from=$_POST["totalQuery"];
$qry=json_decode($_POST["query"]);
$qry->from=$from; }?>
I am trying to get it in the form,
{"data": {"match_all": {}} , "from": 10}
I get the error Object of class stdClass could not be converted to string
json_encodeit back?}at the end of your PHP script?