Ajax registration form

Permalink
I want to implement an ajax registration form. I call the do_register method of the register class and set the dataType: 'json' in the javascript:
var data = $('form#registration-form').serialize();
$.post(
'<?php echo $this->url('/register', 'do_register')?>',
function(data) {
 alert(data);
},
'json'
);


There is also a block in the register class, which checks for the request type and returns a JSON array:
if( $_REQUEST['format']=='JSON' ){
$jsonHelper=Loader::helper('json'); 
echo $jsonHelper->encode($registerData);
die;
}


However, the ajax call doesn't return anything. If I don't specify a dataType, the ajax call returns the whole registration page and I don't want that. I only want the $registerData array in json form. Is that possible?

 
Martificiam replied on at Permalink Reply
I have found the solution.
Use
'<?php echo $this->url("/register", "do_register")?>?format=JSON'
instead of
'<?php echo $this->url("/register", "do_register")?>'