Update: This works in firefox, but does not work on chrome 6, still investigating.
I'm taking an internet programming class and learning various javascript frameworks. I'm working on a mootools problem, and the .get('text') method does not appear to be working as expected 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's 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){
//this seems like it should work according to all mootools docs, but it doesn't. user.getElement('username').get('tag') works, but neither 'html' or 'text' work...retuturning undefineds.
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 documentation) be able to get the text contained in the username tag with .get('text')
. Instead, its returning undefined.
Checking the value of user.getElement('username')
returns the expected
<username>etomai</username>
Running code located here
Try entering the letter "e" in the search field.
I'm stuck at this juncture. Anyone able to point me in the right direction?