$.ajax({ // saving data to rest controller url : "/q/auth/savethis", type: "post", data: ko.toJSON(ViewModel), contentType: "application/json", success: function (result) alert(result.message+" "+result.firstName+" "+result.lastName) ; }
public function post_savethis() { $firstName = \Input::post("firstName"); $lastName = \Input::post("lastName"); // but first just return some data back to the view .. $this->response(array( 'valid' => true, 'message' => 'Did we got any data ? ', 'firstName' => $firstName , 'lastName' => $lastName ), } /* end of savethis */
Phil Sturgeon wrote on Thursday 11th of August 2011:Looks like you are encoding to JSON then decoding again just to make an array. Can't you just send an array?
It looks like you're new here. If you want to get involved, click one of these buttons!