加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

uchome2.0的ajax技术流程研究心得

发布时间:2021-03-30 12:03:56 所属栏目:教程 来源:网络整理
导读:前言: 基于uchomer的插件如果没有使用ajax或flex,可以说无论如何也做不到完美的。而相比于flex,ajax使用的较多。好多插件开发者在研究 uchome的ajax的使用过程中花费了不少时间,此文意在减少插件开发者的研究时间。flex相关插件的说明,敬请关注!此文整

<div class="cnblogs_code" onclick="cnblogs_code_show('510d5782-fab9-45a1-8ca8-1ad673e2b07a')">
<img class="code_img_closed" id="code_img_closed_510d5782-fab9-45a1-8ca8-1ad673e2b07a" style="display: none" src="https://www.52php.cn/res/2019/02-07/12/1c53668bcee393edac0d7b3b3daff1ae.gif" alt=""><img class="code_img_opened" id="code_img_opened_510d5782-fab9-45a1-8ca8-1ad673e2b07a" onclick="cnblogs_code_hide('510d5782-fab9-45a1-8ca8-1ad673e2b07a',event)" src="https://www.52php.cn/res/2019/02-07/12/405b18b4b6584ae338e0f6ecaf736533.gif"&gt;<span class="cnblogs_code_collapse">代码
<div id="cnblogs_code_open_510d5782-fab9-45a1-8ca8-1ad673e2b07a">

?$content)?{??$_SC;??1″);??FALSE);??-cache”);??$_SC[charset]“);???>n”;??”;??exit();???

代码很简单,就是最终编辑内容为标准的xml格式,然后echo出来。实际内容应该是这样的:

<div class="cnblogs_code">

?>?-?>?-??

如下图:

uchome2.0的ajax技术流程研究心得7、script_ajax.js的295行:ajaxframe.attachEvent(’onload’,ajaxpost_load);这是一个监听。实际上当action结束后,这个监听就捕获到onload动作了,紧接着应该运行 ajaxpost_load函数,当然,此时同时把ajaxframe填充好了,填充内容和调用ajaxpost_load函数,哪个在先哪个在后呢?这个问题留给高手回答吧。下面看看ajaxpost_load函数

8、script_ajax.js304行:为了直观,我直接在代码里做代码解读了–红色注释部分

<div class="cnblogs_code" onclick="cnblogs_code_show('8689351b-5be3-46d5-bcbb-eb1264e39308')">
<img class="code_img_closed" id="code_img_closed_8689351b-5be3-46d5-bcbb-eb1264e39308" style="display: none" src="https://www.52php.cn/res/2019/02-07/12/1c53668bcee393edac0d7b3b3daff1ae.gif" alt=""><img class="code_img_opened" id="code_img_opened_8689351b-5be3-46d5-bcbb-eb1264e39308" onclick="cnblogs_code_hide('8689351b-5be3-46d5-bcbb-eb1264e39308',event)" src="https://www.52php.cn/res/2019/02-07/12/405b18b4b6584ae338e0f6ecaf736533.gif"&gt;<span class="cnblogs_code_collapse">代码
<div id="cnblogs_code_open_8689351b-5be3-46d5-bcbb-eb1264e39308">

?function?ajaxpost_load()?{?从刚才的ajaxpostHandle句柄里获取值,实际上获取到了’quickcommentform_{$id}’和’comment_add’两个值,timeout是没有值的?3?0];?1];?2];?定义要显示“搞好了”的div之id,实际上在space_blog_view.htm里有这么一句:?7?你一看便知怎么回事了?8?+?formid;?把页面右上解那个loading…隐藏起来10?showloading(’none’);?if(is_ie)?{?把ajaxframe的内容读出来赋值给s,以备后用。此时s的内容是:13?搞好了14?=?$(’ajaxframe’).contentWindow.document.XMLDocument.text;?else?{?=?$(’ajaxframe’).contentWindow.document.documentElement.firstChild.nodeValue;??为了调试,我在这里alert一下19?+?s);?false;?1)?{??true;??1)?{?1;?else?{?0;??function31?if(func)?{?运行函数和comment_add,设置超时时间为10秒,这里边的formid应该没有什么用。33?这个comment_add函数跳出这个代码段后详说34?formid好像没有什么用35?}?&&?$(formstatus))?{?=?”;?让的内容填充上“搞好了”39?ajaxinnerhtml($(formstatus),?s);???43?层消失44?=?setTimeout(”hideMenu()”,?timeout);?46?=?‘ajaxframe’;?0;??50?

9、好了,到此为止,“评论”按钮下面的“搞好了”已经显示出来了。下面要显示的是评论内容和评论条数了。程序运行到了source/script_manage.js的41行comment_add函数:

<div class="cnblogs_code" onclick="cnblogs_code_show('cccefc5e-ed7b-4a2b-a241-1551c92f1fcd')">
<img class="code_img_closed" id="code_img_closed_cccefc5e-ed7b-4a2b-a241-1551c92f1fcd" style="display: none" src="https://www.52php.cn/res/2019/02-07/12/1c53668bcee393edac0d7b3b3daff1ae.gif" alt=""><img class="code_img_opened" id="code_img_opened_cccefc5e-ed7b-4a2b-a241-1551c92f1fcd" onclick="cnblogs_code_hide('cccefc5e-ed7b-4a2b-a241-1551c92f1fcd',event)" src="https://www.52php.cn/res/2019/02-07/12/405b18b4b6584ae338e0f6ecaf736533.gif"&gt;<span class="cnblogs_code_collapse">代码
<div id="cnblogs_code_open_cccefc5e-ed7b-4a2b-a241-1551c92f1fcd">

?添加评论??2?function?comment_add(id,?result)?{??if(result)?{??=?$(’comment_ul’);??=?document.createElement(”div”);??new?Ajax();??function(s){??+?s);??=?s;???if($(’comment_prepend’)){??=?obj.firstChild;??1){??=?obj.nextSibling;????else?{????if($(’comment_message’))?{??=?”;???if($(’comment_replynum’))?{??=?parseInt($(’comment_replynum’).innerHTML);??1;??+?”;???提示获得积分?29?showreward();????

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读