Handling jQuery serialize() on the backend with PHP

My goal for this one situation is to validate all my form data with my backend PHP code through AJAX. If all the checks on my form don’t go through successfully, the page will not go to the next page specified in the HTML form’s “action” attribute.

On the Javascript side I use the serialize() function to take all my form data and pass it through to action.php.

var data = $(this).serialize();
$.post( "action.php", {
action: "ajax_verify_form",
data: data },
return false;
return false;

On the PHP side:
if($action == "ajax_verify_form"){
$fields = explode("&",$data);
foreach($fields as $field){
$field_key_value = explode("=",$field);
$key = urldecode($field_key_value[0]);
$value = urldecode($field_key_value[1]);
eval("$$key = \"$value\";");

Now I have all the same variables from the client side on the PHP side. Now you can do whatever form-checking you need with PHP.  If you have an error, echo the error so the callback function on the jquery.post() function will catch it.