the A in Ajax is for Asynchronous! just because you .load() something
doesn't mean it's there. It will be there later.

the callbacks are called back when it load is done.

load(url, params, callback)

Load HTML from a remote file and inject it into the DOM.
Returns

jQuery
Parameters

  - *url* (String): The URL of the HTML file to load.
  - *params* (Object): (optional) A set of key/value pairs that will be
  sent as data to the server.
  - *callback* (Function): (optional) A function to be executed whenever
  the data is loaded (parameters: responseText, status and response itself).

Example jQuery Code

$("#feeds").load("feeds.html");

Before

<div id="feeds"></div>

jQuery Code

$("#feeds").load("feeds.html",
 {limit: 25},
 function() { alert("The last 25 entries in the feed have been loaded"); }
);





On 6/5/07, ZebZiggle <[EMAIL PROTECTED]> wrote:


Hi again,

I have a snippit of code that ajax loads content for me. I want to add
target='_blank' to all the anchors before displaying it. I'm trying
thing:

function ...
        $('#foo').load("/get/733/").find('a').each(function() {
            this.target = "_blank";
        });

A similar scheme works fine when I first load the page (non-ajax) ...
but the find/each is not working for load()'ed content.

What am I missing here ... it seems to me the find is not working
because the content is not in the DOM yet. Even if I do:

function ...
        $('#foo').load("/get/733/");

        $('#foo  a').each(function() {
            this.target = "_blank";
        });

It doesn't work. Again, perhaps because the DOM update doesn't occur
until the function returns? Is this correct?

Any ideas what I could be doing wrong here?

Thx,
Sandy




--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ

Reply via email to