ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Loading template via AJAX

February 15, 2011 9:59am

Subscribe [2]
  • #1 / Feb 15, 2011 9:59am

    Frank Harrison

    154 posts

    Hi All

    I’m new to AJAX and seem to be having some problems getting it to work with EE. As a test, I’ve created a template group called ajax and put some simple html in its default index.php file. Then in my site’s root page (index.php in the “site” template group) I’ve got a div with class “content”. I then run the following jquery on it:

    // tell ajax not to cache        
    $.ajaxSetup ({
        cache: false
    });
        
    var loadUrl = "/index.php/ajax/";
    $("div.content").load(loadUrl);

    But instead of loading in my ajax template, it loads in the root page of the site (ie. the page ends up loading itself into div.content).

    Am I missing something obvious here? I tested this on static html pages and it worked fine - but for some reason EE isn’t serving up the right template when it’s called via AJAX - it seems to be just defaulting to calling the root template. Any help would be much appreciated!

    Thanks, Frank

  • #2 / Apr 12, 2011 6:04pm

    thumbtech

    3 posts

    Having this problem, too ... It’s been a while, did you figure it out?

  • #3 / Apr 12, 2011 6:20pm

    thumbtech

    3 posts

    Fixed by setting

    type: “POST”,

    in ajax settings. Apparently GET was adding parameters to the URL (even though no data sent), so ee url parsing was failing.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases