在这里,我一直在开发chat
应用程序。在这里,我想根据用户的chat messages
加载email address
。在这里,我想将email address
传递给后端。
在javascript
中,我想将电子邮件从LoadChat
传递到(".friend").each(function(x){
函数。
它显示在console.log
函数的LoadChat
中,立即变为undefined
。
这是Javascript
代码
$(".friend").each(function(x){
$(this).click(function(){
var name = $(this).find("p strong").html();
var email = $(this).find("p span").html();
var id = $(this).find("p spans").html();
LoadChat(email);
$("#profile p").html(name);
$("#profile span").html(email);
$(".message").not(".right").find("img").attr("src", $(clone).attr("src"));
$('#friendslist').fadeOut();
$('#chatview').fadeIn();
setTimeout(function(){
$('#chatview').fadeOut();
$('#friendslist').fadeIn();
}, 50);
});
});
});
这是另一个LoadChat
函数
<script type="text/javascript">
LoadChat();
setInterval(function () {
LoadChat();
}, 1000);
function LoadChat(email) {
console.log(email);
$.post('handlers/messages.php?action=getMessages&email='+email, function (response) {
var scrollpos = $('#chat-messages').scrollTop();
var scrollpos = parseInt(scrollpos) + 420;
var scrollHeight = $('#chat-messages').prop('scrollHeight');
$('#chat-messages').html(response);
if (scrollpos < scrollHeight){
} else{
$('#chat-messages').scrollTop($('#chat-messages').prop('scrollHeight'));
}
})
}
$('form').submit(function () {
//alert('form is submit jquery');
var message = $('.textarea').val();
if ($(".textarea").val()) {
$.post('handlers/messages.php?action=sendMessage&message='+message, function (response) {
//alert(response);
if (response==1){
LoadChat();
document.getElementById('msgform').reset();
}
});
} else {
myFunction();
}
return false;
})
</script>
任何帮助都将受到高度赞赏
答案 0 :(得分:0)
您在多个地方不带参数的情况下调用 ResultSet rs = null;
try {
Statement stmt = queryDb.createStatement();
rs = stmt.executeQuery(strQuery);
} catch (SQLException e) {
e.printStackTrace();
}
while (rs.next()) {
System.out.println(rs.getString("columnName"));
}
。调用不带参数的函数会将其参数设置为LoadChat()
(如果有)。如果要设置undefined
,请将其作为函数调用的参数提供。
email