您好,欢迎访问一九零五行业门户网

php中如何接收Ajax POST数据

正在加载联系人
ctrl+enter 发送

/** * 发送信息/获取信息 */// 清除定时器function clearchattimers(id){ if(id){ //请除指定用户定时执行 if(apchattimers[id]){ cleartimeout(apchattimers[id]); loadflag = false;// console.log('clear:'+apchattimers[id]); } }else{ //请除所有用户定时执行 for (var i=0;i0){ var _scrollheight = $('.dialog-comment-list').find('li').last().offset().top; $(#post-reply).closest('.site-im-dialog').find('.dialog-comment-list').animate({zoom:1},function(){ $(.dialog-comment-list-box).data('jsp').scrollto(0, _scrollheight); }); } $(#post-reply).removeattr('disabled'); clearinputmessage(); clearchattimers(0); getprivatemessages(uid); }else{ tipsop(json.msg,'error'); $(#post-reply).removeattr('disabled'); } },'json');}
返回 {msg:\u53d1\u9001\u6210\u529f,status:1,data:[]}
单击发送或 ctrl+enter 按钮不抬起 (如图)
如何才能单击发送按钮或者按ctrl+enter 把数据post到php处理 求php代码
回复讨论(解决方案) 你这代码是啥问题 后台获取不到还是啥?说得具体点。
你这代码是啥问题 后台获取不到还是啥?说得具体点。
php 获取不到
你这代码是啥问题 后台获取不到还是啥?说得具体点。
html代码
发送
//发送信息 function sendprivatemessages(){ var uid,message; uid = getrecipientidfromreplybtn(); message = getinputmessage(); if(message === false){ $('.for-post').popover('show'); $(#edit).focus(function() { $('.for-post').popover('hide'); }); return false; } $(#post-reply).attr('disabled','disabled'); // 单击按钮之后 按钮是disabled 禁止的 clearchattimers(0); //index.php?do=webim&action=send_messages post 到 后端处理 // php返回 json数据 {msg:\u53d1\u9001\u6210\u529f,status:1,data:[]} /* 我对js实在不行, 不知php 如何获取 post 数据 */ $.post('index.php?do=webim',{action:'send_messages',uid:uid,smessage:message}, function(json) { if(json.status == '1'){ if($('.dialog-comment-list').find('li').length >0){ var _scrollheight = $('.dialog-comment-list').find('li').last().offset().top; $(#post-reply).closest('.site-im-dialog').find('.dialog-comment-list').animate({zoom:1},function(){ $(.dialog-comment-list-box).data('jsp').scrollto(0, _scrollheight); }); } $(#post-reply).removeattr('disabled'); clearinputmessage(); clearchattimers(0); getprivatemessages(uid); }else{ tipsop(json.msg,'error'); $(#post-reply).removeattr('disabled'); } },'json');}
执行 $.post('index.php?do=webim',{action:'send_messages',uid:uid,smessage:message} ... 后
php 得到
$_get['do'] 为 webim
$_post['action'] 为 send_messages
$_post['uid'] 为 uid 的值
$_post['smessage'] 为 message 的值
执行 $.post('index.php?do=webim',{action:'send_messages',uid:uid,smessage:message} ... 后
php 得到
$_get['do'] 为 webim
$_post['action'] 为 send_messages
$_post['uid'] 为 uid 的值
$_post['smessage'] 为 message 的值
谢了,我以为 action 是get参数
其它类似信息

推荐信息