0

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

1
  • 2
    data: {user : 1234}, instead data: '{user : 1234}', ? Commented Jan 29, 2014 at 11:29

2 Answers 2

1
data : {
'user' : 1234
}

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

dataType : 'json'
Sign up to request clarification or add additional context in comments.

Comments

1

Try this,

 data: {user : 1234}, 

instead of

data: '{user : 1234}',

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.