这是我的php文件
<?php
require_once __DIR__ . '/../../core/FbChatMock.php';
if (isset($_POST['id']))
{
$userId = (int) $_SESSION['user_id'];
$id = htmlentities($_POST['id'], ENT_NOQUOTES);
$chat = new FbChatMock();
$messages = $chat->getchat($userId, $id);
echo json_encode($messages);
}
$chat_converstaion = array();
$chat_converstaion[] = '<table>';
?>
我想将这些$ id和$ userId变量传递给javascript文件,这里是我的javascript文件
getMessage:function(ID)
{
var that = this;
$.ajax({
url: '../forms/ajax/send_id.php',
method:'post',
data: {id: ID},
success:function(data) {
var messages = JSON.parse(data);
for (var i = 0; i < messages.length; i++)
{
var msg = messages[i];
fbChat.addUserMessage('',msg.message);
}
$('.msg_head').val('');
}
});
},
addUserMessage:function (user, message)
{
msgBoxList = $('.msg_box').find('.msg_body');
msgBoxList.append("<div class='msg_a'>"+message+"</div>");
}
};
我想在addusermessage函数里面的空参数处使用这些参数。我是javascript的新手,我将非常感谢帮助。