我正在处理聊天应用程序,这是我的javascript代码。
function PushMessage(e , textarea)
{
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13)
{
//Enter keycode
var text1 = document.getElementById('myTextArea').value;
var div = document.getElementById('textmesage');
div.innerHTML = div.innerHTML + '<br>' + text1;
document.getElementById('myTextArea').value = "";
if (text1.length !== 0) {
opner.sendMessage(text1);
event.preventDefault();
} else {
alert('Provide a message to send!');
}
}
}
从这个上层代码我想调用sendMessage(text1);来自其他页面的ajax函数我也尝试了连接的路径,但它不起作用,这里是我的ajax函数
sendMessage: function(message)
{
alert('fakhir is jumping');
var that = this;
$.ajax({
url: '/ajax/add_msg.php',
method: 'post',
data: {msg: message},
success: function(data)
{
$('#chatMsg').val('');
that.getMessages();
}
});
}