I have a PHP script like so:
$STL = array();
$filter = array();
$filter['sort_by'] = "date_added";
$filter['sale'] = "F";
$filter['per_page'] = "12";
$STL['filter'] = $filter;
echo json_encode($STL);
This gives the following output:
{"filter":{"sort_by":"date_added","sale":"F","per_page":"12"}}
I am trying to use parseJSON like so:
$.ajax({
url: 'myPHP.php',
type: 'post',
data : get_session,
async: false,
dataType: 'json',
success: function(result) {
var json = $.parseJSON(result);
}
});
But I get the following result:
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
I'm guessing the json string isn't formatted correctly in the PHP. What I got wrong?