|
查看: 1151|回复: 1
|
关于AJAX和php!
[复制链接]
|
|
|
- function ajaxmenu(e, ctrlid, timeout, func, offset) {
- var box = 0;
- showloading();
- if(jsmenu['active'][0] && jsmenu['active'][0].ctrlkey == ctrlid) {
- hideMenu();
- doane(e);
- return;
- } else if(is_ie && is_ie < 7 && document.readyState.toLowerCase() != 'complete') {
- return;
- }
- cache = 0;
- divclass = 'popupmenu_popup';
- optionclass = 'popupmenu_option';
- if(isUndefined(timeout)) timeout = 3000;
- if(isUndefined(func)) func = '';
- if(isUndefined(offset)) offset = 0;
- duration = timeout > 10000 ? 3 : 0;
- executetime = duration ? 2000: timeout;
- if(offset == -1) {
- divclass = 'popupmenu_centerbox';
- box = 1;
- }
- var div = $(ctrlid + '_menu');
- if(cache && div) {
- showMenu(ctrlid, e.type == 'click', offset, duration, timeout, 0, ctrlid, 400, 0);
- if(func) setTimeout(func + '(' + ctrlid + ')', executetime);
- doane(e);
- } else {
- if(!div) {
- div = document.createElement('div');
- div.ctrlid = ctrlid;
- div.id = ctrlid + '_menu';
- div.style.display = 'none';
- div.className = divclass;
- $('append_parent').appendChild(div);
- }
- var x = new Ajax();
- var href = !isUndefined($(ctrlid).href) ? $(ctrlid).href : $(ctrlid).attributes['href'].value;
- x.div = div;
- x.etype = e.type;
- x.optionclass = optionclass;
- x.duration = duration;
- x.timeout = timeout;
- x.executetime = executetime;
- x.get(href + '&ajaxmenuid='+ctrlid+'_menu&popupmenu_box='+box, function(s) {
- evaled = false;
- if(s.indexOf('ajaxerror') != -1) {
- evalscript(s);
- evaled = true;
- if(!cache && duration != 3 && x.div.id) setTimeout('$("append_parent".removeChild($(\'' + x.div.id + '\'))', timeout);
- }
- if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
- if(x.div) x.div.innerHTML = '' + s + '';
- showMenu(ctrlid, x.etype == 'click', offset, x.duration, x.timeout, 0, ctrlid, 400, 0);
- if(func) setTimeout(func + '("' + ctrlid + '"', x.executetime);
- }
- if(!evaled) evalscript(s);
- ajaxerror = null;
- showloading('none');
- });
- doane(e);
- }
- showloading('none');
- doane(e);
- }
复制代码 请问以上的代码在写什么? |
|
|
|
|
|
|
|
|
|
|
发表于 25-2-2009 07:19 AM
|
显示全部楼层
其實這裡寫的應該不是完整的代碼. 至少裡面很多的function都看不到.
我猜應該是用AJAX即時去伺服器抓出一個之前已經做好的MENU清並且用DIV的方式顯示出來.
而那個MENU應該是屬於SELECT / OPTION的下來式的的選單.
- function ajaxmenu(e, ctrlid, timeout, func, offset) {
- var box = 0;
- showloading(); // 這個function應該是在畫面上顯示出一個"Loading"的字.
- if(jsmenu['active'][0] && jsmenu['active'][0].ctrlkey == ctrlid) {
- hideMenu(); //如果是之前已經有MENU已經顯示出來就先把那個MENU關掉
- doane(e); // donee()應該是是done event的意思
- return;
- } else if(is_ie && is_ie < 7 && document.readyState.toLowerCase() != 'complete') {
- return; // 如果是IE 7 以下的就跳出
- }
- cache = 0;
- divclass = 'popupmenu_popup'; // 定義div的css class
- optionclass = 'popupmenu_option'; //定義裡面option的css class
- if(isUndefined(timeout)) timeout = 3000;
- if(isUndefined(func)) func = '';
- if(isUndefined(offset)) offset = 0;
- duration = timeout > 10000 ? 3 : 0;
- executetime = duration ? 2000: timeout;
- if(offset == -1) {
- divclass = 'popupmenu_centerbox';
- box = 1;
- }
- var div = $(ctrlid + '_menu');
- if(cache && div) {
- showMenu(ctrlid, e.type == 'click', offset, duration, timeout, 0, ctrlid, 400, 0);
- if(func) setTimeout(func + '(' + ctrlid + ')', executetime);
- doane(e);
- } else {
- if(!div) { //正常的話應該會跑來這裡
- div = document.createElement('div'); //建立新的DIV
- div.ctrlid = ctrlid; // 應該是定義control id之類的吧?
- div.id = ctrlid + '_menu'; // 定義DIV的ID為control ID 加上 "_menu"
- div.style.display = 'none'; // 把之前那個DIV的css style定義為display: none;
- div.className = divclass; //為之前那個DIV加上一個叫做 "divclass"的css class
- $('append_parent').appendChild(div); //把新的DIV附加到parent之下
- }
- var x = new Ajax(); // 建立新的AJAX連接
- var href = !isUndefined($(ctrlid).href) ? $(ctrlid).href : $(ctrlid).attributes['href'].value; //定義AJAX的連接對像.
- x.div = div;
- x.etype = e.type;
- x.optionclass = optionclass;
- x.duration = duration;
- x.timeout = timeout;
- x.executetime = executetime;
- x.get(href + '&ajaxmenuid='+ctrlid+'_menu&popupmenu_box='+box, function(s) { // 叫AJAX以之前定義的連接去抓取MENU.
- evaled = false;
- if(s.indexOf('ajaxerror') != -1) {
- evalscript(s); //如果AJAX沒有出錯的話就執行"s"代碼
- evaled = true;
- if(!cache && duration != 3&& x.div.id) setTimeout('$("append_parent".removeChild($(\'' +x.div.id + '\'))', timeout); //如果時間太長了就放棄
- }
- if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
- if(x.div) x.div.innerHTML = '' + s + ''; //執行以上的代碼後如果沒有出錯的話就把剛才得到的東西丟在剛建立的DIV裡面.
- showMenu(ctrlid, x.etype == 'click', offset, x.duration, x.timeout, 0, ctrlid, 400, 0); // 把MENU顯示出來
- if(func) setTimeout(func + '("' + ctrlid + '"', x.executetime);
- }
- if(!evaled) evalscript(s);
- ajaxerror = null;
- showloading('none'); //把"Loading"的畫面關閉
- });
- doane(e); //event 完成.
- }
- showloading('none'); //把"Loading"的畫面關閉
- doane(e); // event 完成!! done!!!
- }
复制代码 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|