WordPress frontend AJAX Form submission gives 500 internal server error


Staff member
I am creating a custom wordpress plugin that it has a frontend form, and i want the data to be sent to the database with AJAX and also return a response to update the frontend table.

Everything looks good, till i click "submit" button

So my AJAX is :

$('#form').submit(function(event) {

    var formData = {
        'user'              : $('input[name=userid]').val(),
        'cardname'             : $('input[name=card]').val(),
        'setname'             : $('input[name=setname]').val(),
        'quantity'    : $('input[name=quantity]').val(),
        'multiverseid'    : $('input[name=multiverseid]').val()

    // process the form
        type        : 'POST', // define the type of HTTP verb we want to use (POST for our form)
        url         : ''+base_url+'/website/wp-content/plugins/test/public/js/process.php', // the url where we want to POST
        data        : formData, // our data object
        dataType    : 'html', // what type of data do we expect back from the server
        encode          : true,
        success : function(updatedTable) {


 // stop the form from submitting the normal way and refreshing the page


The process.php file that will add the data is :

global $wpdb;

    'user' => $_POST[userid], 
    'cardname' => $_POST[cardname],
     'setname' => $_POST[setname],
     'quantity' => $_POST[quantity],
     'multiverseid' => $_POST[multiverseid] 



$user_ID = get_current_user_id();
$cards = $wpdb->get_row( "SELECT * FROM $wpdb->wp_mycards WHERE user = ".$user_ID."" );

while ($row = mysql_fetch_assoc($cards)) { 

    $data.='<tr><td align="center"><img src="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid='.$row[multiverseid].'&type=card" width="30" height="42" /></td><td align="left">'.$row[cardname].'</td><td align="center">'.$row[setname].'</td><td align="center">'.$row[quantity].'</td></tr>';



 echo $data;

-I run it at firefox and at firebug it gives me 500 internal server error-The post values are fine