当前位置 : 主页 > 网页制作 > Dojo >

Use Dojo to Replace PrototypeJS codes

来源:互联网 收集:自由互联 发布时间:2021-06-15
1.Old PrototypeJS Script: var loc = document.location.pathname;var tail = "webengine/generated/Init"loc = loc.substr(0,loc.indexOf(tail));var url = loc.concat("protect/RouterServlet?NAV_MENU=TRUEGREEN_NAV=TRUE");new Ajax.Request(url,{method

1.Old PrototypeJS Script:

var loc = document.location.pathname;
var tail = "webengine/generated/Init"
loc = loc.substr(0,loc.indexOf(tail));
var url = loc.concat("protect/RouterServlet?NAV_MENU=TRUE&GREEN_NAV=TRUE");
				
new Ajax.Request(url,{method:'get', onSuccess:function(request){
var elemAjxResp = request.responseText;
document.getElementById('com-navigation').innerHTML = elemAjxResp;;
}});

2. Use Dojo Ajax and dom operation;

require(["dojo/_base/xhr", "dojo/dom", "dojo/domReady!"],
    function(xhr, dom) {        
        xhr.get({            
            url: url,            
            load: function(newContent) {
                dom.byId("com-navigation").innerHTML = newContent;
            },            
            error: function() {
			
            }
        });         
});
上一篇:dojo自定义widget
下一篇:dojo readings
网友评论