Results 1 to 3 of 3

Thread: ajax

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default ajax

    is there a way to load images in without the html container?
    i have this
    Code:
    <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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not with AJAX. You could simply write the content to the division though. In jQuery:

    Code:
    <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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    thanks!! will try it out

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •