Reputation: 1020
i m loading a div through jquery
$('#Detailvolunteer').load("http://localhost/../somepage.php")
now after load i get the div content empty although it has loaded successfully.the innerHTML shows nothing. what i want is to check the data and hide the div if empty . but it always shows empty.
Upvotes: 0
Views: 556
Reputation: 15851
you need to proviade a callback function for load. Load()
If a "complete" callback is provided, it is executed after post-processing and HTML insertion has been performed. The callback is fired once for each element in the jQuery collection, and this is set to each DOM element in turn.
$('#Detailvolunteer').load("http://localhost/../somepage.php",function(data){
//hrere do some logic to replace.
});
or even better use like this
$('#result').load('ajax/test.html #container');
When this method executes, it retrieves the content of ajax/test.html, but then jQuery parses the returned document to find the element with an ID of container. This element, along with its contents, is inserted into the element with an ID of result, and the rest of the retrieved document is discarded.
Upvotes: 1