Zend_Json::decode returning null

Posted by davykiash on Stack Overflow See other posts from Stack Overflow or by davykiash
Published on 2010-03-15T11:58:41Z Indexed on 2010/03/15 11:59 UTC
Read the original article Hit count: 754

Filed under:
|

Am trying to validate my form using an AJAX call

$("#button").click(function() {
    $.ajax({                    
        type: "POST",
        url: "<?php echo $this->baseUrl() ?>/expensetypes/async",
        data: 'fs=' + JSON.stringify($('#myform').serialize(true)),                 
        contentType: "application/json; charset=utf-8",
        dataType: "json"
        });
    });

On my controller my code is as follows

//Map the form from the client-side call
        $myFormData = Zend_Json::decode($this->getRequest()->getParam("fs") 
                            ,Zend_Json::TYPE_ARRAY);

        $form = new Form_Expensetypes();
        $form->isValid($myFormData);

My problem is that I cannot validate since Zend_Form::isValid expects an array

Am not quite sure wether the problem is at my serialisation at the client end or Zend_Json::decode function does not function with this kind of JSON parsing.

© Stack Overflow or respective owner

Related posts about zend

Related posts about json-decode