Hi everyone, i got a problem with a json response from an ajax request.
I have the following code :
$.get( "ajax_sous_famille.php",
{"id": $(this).attr("value")},
function(data)
{
// whatever !!!
},
"json"
);
And the called page (ajax_sous_famille.php) is giving me this result :
[{"id":"25","nom":"Pouf slim"},{"id":"26","nom":"Pouf g\\u00e9ant"},{"id":"27","nom":"Pouf XXL"},{"id":"28","nom":"Pouf Int\\u00e9rieur"}]
The info in the resulting string is correct, but here you can see the at the start and end of the line.
It seems not to be a correct Json string and then it crashes my script !
I have another request like this which gives me the good format of resulting data (without the ) and which works perfectly when i decode the Json string to display it.
The difference between the 2 requests is that the one which works returns only 1 array of values like
array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3"
);
and the second one which doesn’t work returns something like
array(
record1(array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3"
);
),
record2(array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3"
);
),
record3(array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3"
);
)
);
Actually, all the records are coming from a database and in the case it doesn’t work, i wanna get several results from this database.
Does anyone have an idea of how i can make my Json answer correctly formated, or how i can achieve this if Json format is not the answer ?
Thanx