Zend and Jquery (Ajax Post)

Posted by Zend_Newbie_Dev on Stack Overflow See other posts from Stack Overflow or by Zend_Newbie_Dev
Published on 2010-12-30T03:30:34Z Indexed on 2010/12/30 3:53 UTC
Read the original article Hit count: 176

Filed under:
|
|
|
|

I'm using zend framework, i would like to get POST data using Jquery ajax post on a to save without refreshing the page.

//submit.js

$(function() {

    $('#buttonSaveDetails').click(function (){
        var details = $('textarea#details').val();
        var id = $('#task_id').val();
        $.ajax({
            type: 'POST',
            url: 'http://localhost/myproject/public/module/save',
            async: false,
            data: 'id=' + id + '&details=' + details,
            success: function(responseText) {
                //alert(responseText)
                console.log(responseText);
            }

        });
    });
});

On my controller, I just don't know how to retrieve the POST data from ajax.

public function saveAction() 
{

    $data = $this->_request->getPost();
    echo $id = $data['id'];
    echo $details = $data['details'];
    //this wont work;
}

Thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery