I am trying to send multiple variables from a php file to ajax using json in an array. The code in the php file works fine and does everything with my database as it should. But as soon as I add dataType: "json" to ajax, nothing else happens in the php file. I did a bit of work on Google, and some people mentioned that this might be a problem with the browser, but so far it doesn't work in firefox, chrome, or IE. I am using the latest version of jQuery.
This is what happens inside php:
<?php
echo json_encode(array("id" => "$realid", "un" => "$username", "date" => "$date"));
?>
And this is the ajax code:
.ajax(
{
url: 'UpdateComments.php',
type: 'POST',
dataType: "json",
data:
{
type: "add",
comment: $("#comment").val(),
id: videoID
},
success: function (data)
{
}
});
I do not know about this, any advice will be very grateful!
source
share