$$('div#makeRequest a') would return an array so i would imagine it wouldnt
be attaching the event properly
try
$('makeRequest').getElement('a').addEvent(.......
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of guillem
Sent: Friday, 5 December 2008 6:06 PM
To: MooTools Users
Subject: Can't make HTML request to work
Hi, i trying to make that code to work:
HTML code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<link rel="stylesheet" href="demo.css" type="text/css" />
<script type="text/javascript" src="../mootools.js"></script>
<script type="text/javascript" src="demo.js"></script>
<title>Request.HTML Demo</title>
</head>
<body>
<h1>Request.HTML</h1>
<h2>Introduction</h2>
<p>
Request.HTML is a subclass of Request built for making XHR
requests
which return HTML content.
</p>
<p>
<div id="makeRequest"><a href="data.html" rel="#" >Get
HTML</a></
div>
</p>
<h2>Result</h2>
<div id="result">Waiting for the request to happen.</div>
</body>
</html>
And the JS file:
window.addEvent('domready', function() {
// You can skip the following two lines of code. We need them to
make
sure demos
// are runnable on MooTools demos web page.
if (!window.demo_path) window.demo_path = '';
var demo_path = window.demo_path;
// --
$$('div#makeRequest a').addEvent('click', function() {
var testons = this.get('href');
req.send();
});
//We can use one Request object many times.
var req = new Request.HTML({url:demo_path+'myURL',
onSuccess: function(html) {
//Clear the text currently inside the results div.
$('result').set('text', '');
//Inject the new DOM elements into the results div.
$('result').adopt(html);
},
//Our request will most likely succeed, but just in case,
we'll add
an
//onFailure method which will let the user know what
happened.
onFailure: function() {
$('result').set('text', 'The request failed.');
}
});
});
Do you guys have any ideas?
By the way, i'm a total beginner.
Thanks for all!