Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5952057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:37:37+00:00 2026-05-22T17:37:37+00:00

if ($this->getRequest()->isXmlHttpRequest()) { $this->_helper->layout->disableLayout(); $ajaxContext = $this->_helper->getHelper(‘AjaxContext’); $ajaxContext->addActionContext(‘view’, ‘html’); $ajaxContext->initContext(); } how does this

  • 0
if ($this->getRequest()->isXmlHttpRequest()) {
    $this->_helper->layout->disableLayout();
    $ajaxContext = $this->_helper->getHelper('AjaxContext');
    $ajaxContext->addActionContext('view', 'html');
    $ajaxContext->initContext();
}

how does this actually work… my ajax get page is local.maker/profile/check

i got ajax to work fine but i dont know what to edit from the above…

$ajaxContext->addActionContext('???', 'html');

ps.. i am requesting a json

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:37:38+00:00Added an answer on May 22, 2026 at 5:37 pm

    I use the following code to use AJAX context helper.

    In your controller create a preDispatch method to set up your contexts like this:

    public function preDispatch()
    {
        $this->_helper->ajaxContext()
                      ->addActionContext('index', array('json', 'html'))
                      ->addActionContext('anotheraction', 'json')
                      ->initContext();
    }
    

    And then in you action methods use:

    public function indexAction()
    {
        if ($this->_helper->ajaxContext()->getCurrentContext() == 'json') {
            // ajax code here
        } else {
            // non ajax code here
        }
    }
    

    Also in your ajax request you must use the variable format to set the current context, for example

    http://www.mydomain.com/index/format/json
    

    to request a json response.

    Note: The context switcher automatically disables the layout and view, any view variable set in the controller will automatically be encoded into a json string and sent.

    I hope this helps

    Kind regards

    Garry

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// Process the forms if (($this->getRequest()->isPost()) && ($this->getRequest()->isXmlHttpRequest())) { // Initiate response $status =
I would like to send a html string with a GET request like this
i have this situation foreach($front->getRequest()->getParams() as $key => $value){ if ($value == '1'){ $$key
i am following this tutorial: http://tutorial.symblog.co.uk/docs/validators-and-forms.html at the swift mailer part i am not
I have the following piece of code. QNetworkAccessManager *man = new QNetworkAccessManager(this); QNetworkRequest getRequest;
below is the code i'm using to test this: <cfif structkeyexists(form, submitted)> <cfdump var=#getPageContext().getRequest().getParameterMap()#>
I found this code here while trying to understand what an actionstack does and
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.