Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to use ajax, to load different pages in

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1498 Views
  • duskydesigns
    Avatar
    Community Member
    15 Posts

    How to use ajax, to load different pages in Link to this post

    Hi all,

    I got a question about the workings of ajax calls within silverstripe. Im trying to load external pages into one page, but so far its failing. What i need to do is get the title, description and images. Im trying to do this through jQuery but i cant get it to work. I think ive forgot something or am just missing something huge. If anyone can help me out that would be appreciated. I tried ajax_recipes but i think its deprecated because i got a warning that a string did not exist.

    this is what im trying to do:
    http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
       
    $.ajaxSetup ({
          cache: false
       });

       var ajax_load = "<img src='themes/duskydesigns/images/load.gif' alt='loading...' />";
    $(".portfolio-product").click(function(){
          var url = $(this).attr( 'rel' ) + 'ajax';
          $("#result").html(ajax_load).load(url);
          alert( url );
    });

    Im trying to get the url through the rel wich is just #relativelink of the page in question. Im familiar with javascript but not much with ajax calls and especially not in silverstripe, any help would be appreciated!

  • moloko_man
    Avatar
    Community Member
    72 Posts

    Re: How to use ajax, to load different pages in Link to this post

    afaik, ajax_recipes is out of date and deprecated.

    I've done many ajax calls pulling in children pages into a "holder" page. and they work fine. I guess I'm "missing something huge" by not seeing all your code. What do you mean by external pages, are you pulling in random pages from your site, child pages, another site's pages?

    while your jquery looks fine, I would recommend using .live instead of .click, for a lot of reasons that this forum isn't meant for.
    $(".portfolio-product").live('click', function() {
    your jquery load stuff here
    }};

    I would check to see if your function is even being called, by throwing in an alert(); then if so have it load to a static div tag on your page and see if its getting loaded.

    1498 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.