Skip to main content

Bug Tracker

Side navigation

#867 closed bug (worksforme)

Opened January 23, 2007 07:51AM UTC

Closed January 23, 2007 10:50AM UTC

Last modified June 19, 2007 08:49AM UTC

multiple ajax only update one div

Reported by: anonymous Owned by:
Priority: major Milestone: 1.1
Component: ajax Version:
Keywords: Cc:
Blocked by: Blocking:
Description

when trying to load multiple ajax only the last div is updated, when you switch the script in ready part the last one (the div) will always be updated but it will succeed calling both ajax.

function getNews(id){ [b]

action = id.substring(0,4);

id = id.substring(4);

$.getJSON("/labs/json.php?action=" + action + "&id=" + id,function(json){

$("#" + action + "NewsOverview").html(json.value.news);

});

}

$(document).ready(function(){

getNews($("#panelHottNews .gamesNewsSelected").attr("id"));

getNews($("#panelGameNews .gamesNewsSelected").attr("id"));

}

Attachments (0)
Change History (1)

Changed January 23, 2007 10:50AM UTC by joern comment:1

resolution: → worksforme
status: newclosed

As documented, attr("id") returns the ID of the first matched element. Try this instead:

$("#panelHottNews , #panelGameNews").find(".gamesNewsSelected").each(function() {
  getNews(this.id);
});

Please consider reporting something like this to the discussion list first. Chances are good that you get help much faster, and if it really is a bug, you can still report it as one.