Results 1 to 4 of 4

Thread: Ajax content refresh

  1. #1
    New user
    Join Date
    08-30-13.
    Posts
    7

    Default Ajax content refresh

    Hi sorry for my horrible English. I need generate my module content only from template. Without JS heather etc. But i don't know how. Thanks for help.

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Ajax content refresh

    Put some more effort in asking help; show what you need and show what you tried. In other words: give some more info, in horrible English.

  3. #3
    New user
    Join Date
    08-30-13.
    Posts
    7

    Default Re: Ajax content refresh

    THX the problem is solved by Ajax plugin from repository and any conditions in template. I need simply way for pure HTML output from my own module for ajax call.

  4. #4
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Re: Ajax content refresh

    You just need to echo your HTML out. You can get the HTML for any Contao template by using the parse() method.

    If your template is stored in $this->Template all you need to do is:

    Code:
    $html = $this->Template->parse();
    
    echo $html;
    exit();
    This will output your module's HTML and nothing else.

    For AJAX calls I normally use JSON, this makes it easy for your JavaScript to work with:

    Code:
    $html = $this->Template->parse();
    
    header('Content-type: application/json');
    echo json_encode(array('html' => $html));
    exit();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •