Update: this works in firefox, but does not work on chrome 6, still exploring.
I take a programming class on the Internet and study various javascript frameworks. I am working on a mootools issue, and the .get ('text') method does not seem to work properly on responseXML.
Here's the responseXML:
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user>
<username>etomai</username>
<first_name>Joe</first_name>
<last_name>Smith</last_name>
</user>
<user>
<username>hehhh</username>
<first_name>hee</first_name>
<last_name>lkii</last_name>
</user>
</users>
Here is the code:
function update_list() {
var req = new Request({
url: 'users.php',
method: 'get',
data: {
'term': $('search').value
},
onComplete: function(responseText, responseXML){
$('list').empty();
responseXML.documentElement.getElements('user').each(function(user){
console.log(user.getElement('username').get('text'));
var copy = $('template').clone();
$('list').grab(copy);
$(copy).removeClass('hidden');
$(copy).getChildren()[0].set("text", "username goes here")
$(copy).getChildren()[1].set("text", "name goes here")
})
}
}).send();
}
As indicated in the comment, on the line console.log(...I should (according to the documentation) get the text contained in the username tag with .get('text'). Instead, undefined is returned.
Checking the value user.getElement('username')returns the expected
<username>etomai</username>
The code run is located here.
Try typing the letter "e" in the search field.
I am stuck at this point. Anyone who can point me in the right direction?