Access to .load -ed Elements
Hey guys.. i m quite new to JS and jquey.. well i tried to create a div container with JS.. then i loaded a .php page and .hide() it.
now i want to document.getElementById() elements which i loaded with jquery ajax .load method.. but it seems
that the div i created has no childnodes !?
strange: i can fadeIn() the div i created and it shows the loaded content but i cant access the elements inside!?
Code:
- var wrapper = document.getElementById('sitewrapper');
- var testdiv = document.createElement('div');
- testdiv.setAttribute('id','mydiv');
- wrapper.appendChild(testdiv);
- $("#mydiv").load('php/test.php');
- $("#mydiv").hide();
Inside test.php there are several other div-containers like "foobar". And if i:
- alert(document.getElementById('foobar'));
It displays: null. But if > $("#mydiv").fadeIn(); < i can see the content containing the "foobar" div =(
In other words.. i want to manipulate divs i already .load() -ed with ajax.
help >.<
------------------------
UPDATE:
------------------------
Found a solution in another Thread including this sentence:
"Don't use .load and use $.ajax instead. Although I know it is frowned upon as "bad" javascript practice the only way I could get it to work was to use the async:false option."
This way i can manipulate the loaded elements afterwards ;)
bye~