Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » JSON object request response using AJAX

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

Page: 1
Go to End
Author Topic: 1964 Views
  • Rubin
    Community Member
    2 Posts

    JSON object request response using AJAX Link to this post

    I managed to connect to a JSON server using ajax and the sapphire Restful server api, but I am not able to display the dynamic data using a template file as my module code is not able to find the template file.Upon a ?debug_request=1. the code stops execution here
    Latest request params: array (
    'Action' => 'display',
    'ID' => '8298574',
    'OtherID' => NULL,

    and if I use the $this->renderWith('displaypage'); or return $this->renderWith(array('displaypage','Page')); on my dataobject it goes for an infinite loop.

    template code in file is
    <% if display %>
    <% end_if %>

    Is there anyway that my controller can default to handle request as the above and display the template both on AJAX and without.....?

    Any thoughts will be helpful

    Rubin Thomas
    (SS Newbie)

  • martimiz
    Forum Moderator
    1086 Posts

    Re: JSON object request response using AJAX Link to this post

    I do see an infinite loop coming up - if I get you right, that is. Looks like your url is something like


    This means action 'display' will trigger the display() method on your page. This method then starts to render you page using your template. In your template, the <% if display %> again triggers your display() method that then starts to render your page using the template, and... Loop accomplished!

    So if this is the situation, you could try and remove <% if display %> If something really does need checking, you could create some CheckFirst() method in your page controller and use <% if CheckFirst %>

    Hope this makes some sense

  • Rubin
    Community Member
    2 Posts

    Re: JSON object request response using AJAX Link to this post

    Hi Martimiz,

    Thanks for the great help....It could be an infinite loop but I dont know which template is being assigned to my controller basically...
    basically my url is something like this:


    where displaymanager is my module I am developing... and the page I am using is
    display and the action is also display and the ID is 8298575 via an ajax call
    'Action' => 'display',
    'ID' => '8298575',
    'OtherID' => NULL,

    Is this because I cannot use a page name as display and the method as the same "display"

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.