Jump to:

3392 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » 500 Server Error when trying to load template via Ajax

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

Page: 1
Go to End
Author Topic: 1101 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    500 Server Error when trying to load template via Ajax Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: 500 Server Error when trying to load template via Ajax Link to this post

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

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: 500 Server Error when trying to load template via Ajax Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: 500 Server Error when trying to load template via Ajax Link to this post

    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.

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: 500 Server Error when trying to load template via Ajax Link to this post

    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.

    1101 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.