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 7987415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:08:33+00:00 2026-06-04T12:08:33+00:00

How can I stop Layout rendering, when sending request through AJAX.. The problem I

  • 0

How can I stop Layout rendering, when sending request through AJAX..
The problem I face is json data is echoed on the browser, not passed to tha call back function of jquery

here’s my script

jQuery.ajax({
    url: "/getPrivileges",
    type: "POST",
    dataType: 'JSON',
    success: function(privileges){
        alert('hellooo');

        buildTree(privileges,".privBox h2");
        if($(".privPrivilege"))
            $("#loading").css("visibility","hidden");
    },
    error: function (request, status, error) {
        alert('Error'+request.responseText);
    }

});

and here’s the routing

resources.router.routes.privilege.route = /getPrivileges
resources.router.routes.privilege.defaults.module = privileges
resources.router.routes.privilege.defaults.controller = privilege
resources.router.routes.privilege.defaults.action = get-privileges

and here’s my controller

  public function getPrivilegesAction() {

        if ($this->getRequest()->isXmlHttpRequest()) {
         ...........
         ...........
          $this->_helper->json($appPrivArray);
          $this->_helper->viewRenderer->setNoRender(TRUE);
          $this->_helper->layout->disableLayout();
          $response = $this->getResponse();
          $response->setHeader('Content-type', 'application/json', true);
   }


 }

First I face that layout still rendered but now the json is printed on the screen, even I don’t have get-privileges.phtml view page.

and in the init() method of the controller, I make like this

 public function init() {
    $ajaxContextSwitch = Zend_Controller_Action_HelperBroker::getStaticHelper('AjaxContext');
    $ajaxContextSwitch->setDefaultContext('json');
    $ajaxContextSwitch->addActionContext('getPrivileges', 'json');
    $ajaxContextSwitch->initContext();
}

how can I make response deliver to the call back function of jquery!
It’s important to mention that not all urls has custom routes..

please help, because I almost will retire from development using Zend framework !!

  • 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-06-04T12:08:35+00:00Added an answer on June 4, 2026 at 12:08 pm

    In the action, you just need to use

    $this->_helper->json($appPrivArray)
    

    You do not need to use setNoRender or anything else.
    And in the Javascript you do not need to use dataType: 'JSON',
    I tested this, should work fine.

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

Sidebar

Related Questions

How can I stop sending data to the server if the button allready has
Is there a way I can stop all processes in a certain directory through
Is there any method so that I can stop syncing to gmail. I want
I have looked and tried but don't see where I can stop some being
I'm trying to write a program that can stop and start services using SilverLight
How can I stop a background thread on keyboard flip in android?
How can I stop a build, and notify the user if a file does
How can I stop the ABAP extended program check (SLIN) from reporting errors in
How can I stop this from happening, it is grabbing files in .svn folders
How can i stop progress bar gif image when i stopped processing by clicking

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.