views:

66

answers:

1

Am am successfully parsing and sending json values from my client for my server side controller to receive and decode

$("#test2").click(function() {
    $.ajax({                    
        type: "POST",
        url: "<?php echo $this->baseUrl() ?>/expensetypes/add",                 
        data: JSON.stringify(wrapFormValues($('#expensetypes'))),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg){
         alert( "Data Saved: " + msg );
            }
        });
    });

However in my controller the code $this->getRequest()->getPost() doesn't seem to receive the json object that my client is sending though firebug clearly shows that my json object is being parsed and sent.

What am I missing?

A: 

try

print_r($this->getRequest->getParams());

and see what that shows you

Kasia Gogolek
It returns the value "Array" only and not the JSON object am expecting.
davykiash
what does wrapFormValues do? I take it $('#expensetypes') is a form? did you try to leave out wrapFormValues and just stringify the form?
Kasia Gogolek
Thanks. It lead me to the right solution.
davykiash