Skip to content

Instantly share code, notes, and snippets.

@ubermuda
Created January 26, 2010 12:24
Show Gist options
  • Save ubermuda/286797 to your computer and use it in GitHub Desktop.
Save ubermuda/286797 to your computer and use it in GitHub Desktop.
<?php
class userActions extends sfActions
{
public function executeCheckUsername(sfWebRequest $request)
{
$username = $request->getParameter('username');
$availability = (bool) Doctrine_Core::getTable('User')->checkUsername($username);
return $this->renderText(json_encode($availability);
}
}
<script type="text/javascript">
$.get(
'<?php echo url_for('ajax_check_username'); ?>',
{
username: $('input#username').val()
},
function(data)
{
// do stuff here
}
);
</script>
ajax_check_username:
url: /user/checkusername
param: { module: user, action: checkUsername }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment