====== Request.HTML ====== A common practice with Ajax is to update the content of a DOM element with the results of an Ajax request. In other words, fetch new html and replace the inner HTML of some DOM element with the new HTML. MooTools provides a //[[00-request|Request]]// extension that automates this for you. Here is the [[http://docs.mootools.net/Request/Request.HTML|documentation for Request.HTML.js]]. It takes all the same options as //Request// plus three new ones:
new Request.HTML({
url: '/Ajax.Request.Example.html',
method: 'get',
update: 'ajaxExample',
evalScripts: true, /* this is the default */
onComplete: function(){console.log('ajax complete!')}
}).send();
Note that you can keep the Request object around:
var myRequest = new Request(...);
Also note that creating an instance of the class doesn't actually fire the request; you need to call the method //.send()// to do that.