5

I'm trying to access a partial template via AJAX from a template group but I keep getting a 403 forbidden or 404 not found error.

I'm using the great Ajax-include pattern Jquery script from the Filament Group. This script relies on you specifying the html file you want to retrieve from a data attribute in the template; could that have something to do with why I'm getting a 403/404?

I've tried all combinations of paths to the template but still get the same result. I've also tried naming the full path, including the .group, with no success. If I put the HTML file in the root of the site everything works fine.

All templates have been synced and saved as files.

  • Path to templates: /assets/templates/default_site/
  • Template group: site.group (default template group)
  • Template: footer-resource-menu.html

Template code:

<ul>
<li class="dropdown" data-append="footer-form-webmail.html" data-media="(min-width: 50em)">
    <a href="#nowhere" class="dropdown-toggle" data-toggle="dropdown">My Island <b class="caret"></b></a>
</li>
<li>…</li>
</ul>

UPDATE This was due to the .htaccess file being missing from web root.

1 Answer 1

8

What is the path to load the template in your browser, through EE (like a normal page on the EE site)? Did you try using that path, too? That would be the one I'd expect to work. You'd want to do this anyway if there are any EE tags in the template, to be sure they get parsed.

If you try to access the URL of a template file directly with the browser you will get a 403 error. The error is given because EE puts a .htaccess file in your templates folder that has deny from all -- so it prevents templates from being accessed directly, rather than through EE.

So, assuming you are removing index.php, if the partial you are trying to load is the EE template something.html which is located in the EE template group partials.group, the path to use is /partials/something

To test the path is good I would first load it in the browser directly, as one normally would an EE template. If there are no errors, then that path should work with ajax.

8
  • Currently this is running out of the index.html template in the default template group. So: / would be to the root file. The partial template is in the same default directory, so: /footer-resource-menu.html
    – since1976
    Commented Nov 16, 2012 at 3:25
  • So, assuming you are removing index.php from your URL, have you tried this path: /footer-resource-menu ? I would expect /footer-resource-menu.html would give a 404 error since that isn't a valid URL as EE sees it.
    – Alex Kendrick
    Commented Nov 16, 2012 at 3:32
  • 1
    Actually, the path to try would be /template-group-name/footer-resource-menu ... Edited my answer.
    – Alex Kendrick
    Commented Nov 16, 2012 at 3:35
  • Yup you are right index.php has been removed via htaccess. Neither of those paths seem to work. I've tried all sorts of different combinations. Frustrating.
    – since1976
    Commented Nov 16, 2012 at 3:44
  • 2
    Helps if you actually have an .htaccess file in the root of your site. Oh the shame 8-O @Alex Kendrick Apologies for wasting your time. Thanks for responding though.
    – since1976
    Commented Nov 16, 2012 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.