javascript - AJAX call sending JSON data -
i working on chat system refreshes automatically using ajax. first using jquery $.post function, since wanted return json data php script, want use $.ajax function. script worked using $.post function, can not return json. relevant code: javascript: $.ajax({ url: "pages/loadmessage.php", type: "post", data: {"c": geturlparameter("c"), "t": messagetime}, datatype: "json", success: function(pdata){ console.log(pdata); }, error: function(xhr, status, error) { alert(error + status); } }); php code: <?php require_once("../init.php"); header('content-type: application/json'); if (input::exists() && input::get("c") && input::get("t")) { $chat = new chat($user->data()->id, input::get("c")); $messages = $chat->getnewmessages(input::get("t"), $user->data()->id); if ($messages) ...