Display data requested by an ajax.load() call once complete, not during the call.
Posted
by niczoom
on Stack Overflow
See other posts from Stack Overflow
or by niczoom
Published on 2010-05-14T03:07:11Z
Indexed on
2010/05/14
3:14 UTC
Read the original article
Hit count: 244
My jQuery code (using ajax) request's data from a php script (pgiproxy.php) using the following function:
function grabPage($pageURL) {
$homepage = file_get_contents($pageURL);
echo $homepage;
}
I then extract the html code i need from the returned data using jQuery and insert it into a div called #BFX, as follows:
$("#btnNewLoadMethod1").click(function(){
$('#temp1').load('pgiproxy.php', { data : $("#formdata").serialize(), mode : "graph"} , function() {
$('#temp').html( $('#temp1').find('center').html() );
$('#BFX').html( $('#temp').html() );
});
});
This works fine. I get the html data (which is a gif image) i need displayed on screen in the correct div.
The problem is i can see the html data loading into the div (dependant on network speed), but what I want is to insert the extracted html code into #BFX ONLY when the ajax request has fully completed.
© Stack Overflow or respective owner