Stopper
Stopper

Reputation: 411

Three JSON strings in one AJAX request conflicting in Zend

I have three different request for my ajax:

$result = Map_Model_Map_Factory::getCityByRegionAlias($alias);
$resultCountUsers = User_Model_User_Factory::countUserByRegion($alias);
$resultCountPartners = User_Model_User_Factory::countPartnersByRegion($alias);

First request works pretty well. But second and third conflicts with each other. If $this->_helper->json($resultCountUsers); comes first, then it works:

$this->_helper->json($resultCountUsers);
$this->_helper->json($resultCountPartners);
$this->_helper->json($result);

I get what I need countUsers: "1" but I don't have countPartners. And vice versa, if $this->_helper->json($resultCountPartners); comes first, then I get countPartners without countUsers.

Maybe somebody know, what's going on and how I can receive that.

Upvotes: 0

Views: 74

Answers (1)

halfer
halfer

Reputation: 20467

I don't use Zend, but there is clearly a problem: you are not providing attribute names for the JavaScript object. I wonder whether you are overwriting each response with the next one.

See what effect this has in your AJAX viewer:

$this->_helper->json(
    array(
        'resultCountUsers' => $resultCountUsers,
        'resultCountPartners' => $resultCountPartners,
        'result' => $result,
    )
);

Upvotes: 2

Related Questions