How do you do this (jQuery code) in MooTools? -


jquery code:

$.get('/', function(d) { alert($(d).find('a').length); }); 

specifically running selector on returned content of xmlhttprequest...

mootools code:

var opt = { url : '/', oncomplete : function(d) { alert(d); } }; new request(opt).send(); 

what do d inside of oncomplete?

you need use request.html though (so returns html tree selector can crawl through)

new request.html({     url: '/',     method: 'get',     oncomplete: function() {         // normalise collection can apply methods it.          console.log($$(this.response.tree).getelement("a.foo")); // or getelements()     } }).send(); 

http://www.jsfiddle.net/dimitar/nf2jz/477/

oncomplete: function(responsetree, responseelements, responsehtml, responsejavascript) first named arg response tree (if keeping this bound else)

in case, can do: (within oncomplete) console.log(this.response) , inspect arrives. if no element collection (normal request) can inject this.response.text new element , run selector on it.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -