Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

JSON object request response using AJAX


3 Posts   1976 Views


14 January 2011 at 10:32am Community Member, 2 Posts

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)


16 January 2011 at 4:41am Forum Moderator, 1091 Posts

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 :-)


17 January 2011 at 10:10am Community Member, 2 Posts

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"