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 /

500 Server Error when trying to load template via Ajax


Reply


5 Posts   1189 Views

Avatar
Ryan M.

Community Member, 309 Posts

22 October 2010 at 4:45pm

Hello, am getting a 500 Internal Server error in Firebug when I try to load a .ss template via Ajax. I'm following the Ajax basics recipe to a T.

Any ideas?

Avatar
Willr

Forum Moderator, 5513 Posts

22 October 2010 at 5:21pm

Put the site in dev mode or look at your server error logs.

Avatar
Ryan M.

Community Member, 309 Posts

22 October 2010 at 7:44pm

Its been in dev mode the whole time and the error logs aren't showing anything out of the ordinary.

Avatar
Willr

Forum Moderator, 5513 Posts

23 October 2010 at 12:17am

Well thats strange, can you track it down to a specific line (by commenting out code). Post some more information about the function. What happens when you hit the url directly rather than via with ajax.

Avatar
Ryan M.

Community Member, 309 Posts

26 October 2010 at 10:36am

Here's the function:

function showArticleImages() {
      if($this->isAjax) {
      if($photos = DataObject::get("Photo", "ProfileID = {$this->ID}")) {
          return $this->customise(array(
             'Photos' => $photos   
          ))->renderWith('articleImages');
         } else {
            return "Oops, you don't have any photos uploaded yet. <a href=\"{$this->Link('newPhoto')}\" onclick=\"confirmExit('{$this->Link('newPhoto')}'); return false;\">Click here to upload some</a>.";
         }
    } else {
      return Array();
   }
   }

When I go to the page url directly, it just displays the parent page template. Template file, articleImages.ss, is residing in the templates folder next to the top-level Page.ss so that it doesn't pull the header or footer in.

The Ajax works fine though, no problem with that.