Skip to content

Commit

Permalink
CHAT MDL-8224, use json encoded success message
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Sep 14, 2010
1 parent b6845db commit 529817c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion mod/chat/chat_ajax.php
Expand Up @@ -16,6 +16,8 @@

//TODO: use standard CLI_SCRIPT support here (skodak)

define('AJAX_SCRIPT', true);

require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once(dirname(__FILE__) . '/lib.php');

Expand Down Expand Up @@ -85,7 +87,8 @@

$DB->insert_record('chat_messages', $message);
$DB->insert_record('chat_messages_current', $message);
echo 200;
// response ok message
echo json_encode(true);
add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id);

ob_end_flush();
Expand Down
10 changes: 6 additions & 4 deletions mod/chat/gui_ajax/module.js
Expand Up @@ -167,10 +167,13 @@ M.mod_chat_ajax.init = function(Y, cfg) {
},

send_callback : function(tid, outcome, args) {
if (outcome.responseText == 200) {
this.sendbutton.set('value', M.str.chat.send);
this.messageinput.set('value', '');
try {
var data = Y.JSON.parse(outcome.responseText);
} catch (ex) {
return;
}
this.sendbutton.set('value', M.str.chat.send);
this.messageinput.set('value', '');
clearInterval(this.interval);
this.update_messages();
var scope = this;
Expand All @@ -180,7 +183,6 @@ M.mod_chat_ajax.init = function(Y, cfg) {
},

talkto: function (e, name) {
console.info(name);
this.messageinput.set('value', "To "+name+": ");
this.messageinput.focus();
},
Expand Down

0 comments on commit 529817c

Please sign in to comment.