I am trying to create a small ajax chat system (just for this) and I am using prototype.js to handle the ajax part.
One thing I read in the help is that if you return the json data, the callback function will populate that json data in the second parameter.
So, in my php file that is being called, I have:
header('Content-type: application/json'); if (($response = $acs_ajch_sql->postmsg($acs_ajch_msg,$acs_ajch_username,$acs_ajch_channel,$acs_ajch_ts_client)) === true) echo json_encode(array('lastid' => $acs_ajch_sql->msgid)); else echo json_encode(array('error' => $response));
In an ajax request, I have:
onSuccess: function (response,json) { alert(response.responseText); alert(json); }
The warning response.responseText gives me {"lastid": 8}, but json gives me null.
Does anyone know how I can make this work?
javascript prototypejs ajax php
AntonioCS
source share