I'm trying to get a variable from my ajax call:
$.ajax({
type: "POST",
url: "insert",
data: { title:title, start:dstart, end:dend },
contentType: "application/json",
dataType : 'json',
success : function(data) {
data = JSON.parse(data);
console.log('data = '); // is showing the data with double quotes
console.log(data);
}
});
and there is my PHP:
$id = $calendar->getId();
$json = array ( 'id' => $id );
var_dump(json_encode($json));
json_encode($json);
And with my var_dump
I can see my json_encore
, like that for example:
string '{"id":156}' (length=10)
but in my ajax()
success, console.log()
don't show anything in my console.
Where can I see if my success: function(data)
is empty or not ? I would just catch the id in my ajax success.
UPDATE : issue fixed. in fact i'm working with symfony, and I haven't seen that on my action insert where is my PHP, the page called by symfony (indexSuccess.php) was not empty which was why its not working at all.)