Use Dojo to Replace PrototypeJS codes

前端之家收集整理的这篇文章主要介绍了Use Dojo to Replace PrototypeJS codes前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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() {
			
            }
        });         
});
原文链接:https://www.f2er.com/dojo/291456.html

猜你在找的Dojo相关文章