luca.p.alexandru
luca.p.alexandru

Reputation: 1750

Jquery ajax request in with zend framework

I make a jquery ajax request like so:

$.ajax({
            type: 'post',
            data: '{user : 1234}',
            url: '../../mycontroller-ajax/sort',
            success: function (response) {
                alert(response);
            }
        }
    );

however, in the controller/action part, I disable the view first

$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

but if I echo the

$_POST['user'] 

It says that the index is not defined

Upvotes: 0

Views: 84

Answers (2)

Krish R
Krish R

Reputation: 22711

Try this,

 data: {user : 1234}, 

instead of

data: '{user : 1234}',

Upvotes: 1

Makrand
Makrand

Reputation: 587

data : {
'user' : 1234
}

Will definately help but i guess you will also need to include :

dataType : 'json'

Upvotes: 1

Related Questions