I try to implement an ajax request in my django app to get the number of spectators of a flash video recorder I implemented in my app. This number is in an xml file.
Here the js I used did in my template:
var url = window.location.pathname.split('/');
var id = url[2]; // The id of my video is www.mysite/video/ID.com
setInterval(function() {
$.ajax({
type: "GET",
url: "http://myxmlfiles",
success: parseXml
});
}, 2000);
function parseXml(xml){
$(xml).find("user").each(function() {
if($(this).attr("id") === id) {
$(".DubScore").html($(this).attr("count"))
}
});
}
And in my html:
<div class="DubScore"> </div>
The xml file renders:
<streams>
<user id="3" count="1"/>
</streams>
The problem is nothing appears. I really don't know what I did wrong.
Any advice would be great,
EDIT: When I run my js console, I can see the number of spectators, as I wanted. So the only problem is that it doesn't display this number into my div. The problem is between the js and the html. If you have any idea on how to fix it, it would be great. Thanks