PDA

View Full Version : ajax



ggalan
08-25-2010, 03:27 AM
is there a way to load images in without the html container?
i have this


<div id="target"></div>
<p><a href="#" class="ajaxtrigger">Let there be AJAX magic</a></p>


and this jQuery code:

$('.ajaxtrigger').click(function(){
$('#target').load('ajaxcontent.html');
});


but the file ajaxcontent.html is just a container for a jpg
trying to minimize the number of files

jscheuer1
08-25-2010, 08:09 AM
Not with AJAX. You could simply write the content to the division though. In jQuery:


<div id="target"></div>
<p><a href="#" class="trigger">Let there be magic</a></p>


and this jQuery code:

<script type="text/javascript">
$('.trigger').click(function(e){
e.preventDefault();
$('#target').empty().append('<img src="my.jpg" width="150" height="125" alt="original image" title="">');
});
</script>

ggalan
08-25-2010, 04:19 PM
thanks!! will try it out