我正在使用 php、bootbox 和 ajax 开发聊天来提交表单,对,但我不能用 ajax 提交表单!
$(document).ready(function(){
$("#startchat").click(function(){
bootbox.confirm("<center><form id='infos' method='POST' action=''>\
<p style='font-size:25px'>Formulário para Inicialização do Chat</p>\
Nome: <input type='text' name='nome'></input><br/><br/>\
Email: <input type='text' name='email'></input>\
</form></center>", function(result) {
if(result){
$('#infos').submit();
$.ajax({
type: 'post',
url: 'dateRecd.php',
data: 'nome=' + nome + '&email=' + email,
success: function(data){
alert(nome+' e '+email);
}
});
}
});
});
});
好吧,我需要将表单提交到下一页dateRecd.php插入日期并使用两个参数调用这个聊天函数 chatWith(id,name),即开始聊天,Id 和 Name,它们是在 mySQL 中获取的数据!
我不知道哪里错了,我第一次使用 bootbox
<a href="javascript:void()" id="startchat">
<img src="banner.jpg">
</a>