Getting JSON and putting it in a table using jQuery and PHP How can I improve this code?

jQuery: 

$.ajax({
   url: "get_attributes.php",
   type: "post",
   datatype: "json",
   data: {
       wtype: red_type
   },
   success: function (data) {
       var toAppend = '';
       if (typeof data === "object") {
           toAppend += "&lt;tbody&gt;";
           toAppend += "&lt;tr&gt;&lt;/td&gt;&lt;td class=datalabel&gt;Type:&lt;/td&gt;&lt;td&gt;" + data['type'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Health:&lt;/td&gt;&lt;td&gt;" + data['health'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Attack:&lt;/td&gt;&lt;td&gt;" + data['attack'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Defense:&lt;/td&gt;&lt;td&gt;" + data['defense'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Speed:&lt;/td&gt;&lt;td&gt;" + data['speed'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Evade:&lt;/td&gt;&lt;td&gt;" + data['evade'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;tr&gt;&lt;td class=datalabel&gt;Special:&lt;/td&gt;&lt;td&gt;" + data['special'] + "&lt;/td&gt;&lt;/tr&gt;";
           toAppend += "&lt;/tbody&gt;";
           $("tbody").remove();
           $("#red_form table").append(toAppend);
       }
   }
   });


PHP:

    &lt;?php
header("Content-Type: application/json");

$wtype = $_POST['wtype'];

$attributes = array();

if($wtype == 'Ninja'){
    $attributes['type'] = 'Ninja';
    $attributes['health'] = '40-60';
    $attributes['attack'] = '60-70';
    $attributes['defense'] = '20-30';
    $attributes['speed'] = '90-100';
    $attributes['evade'] = '0.3-0.5';
    $attributes['special'] = 'There is a 5% chance of 2x attack';
}
else if($wtype == 'Samurai'){
    $attributes['type'] = 'Samurai';
    $attributes['health'] = '60-100';
    $attributes['attack'] = '75-80';
    $attributes['defense'] = '35-40';
    $attributes['speed'] = '60-80';
    $attributes['evade'] = '0.3-0.4';
    $attributes['special'] = '10% chance of restoring +10 health when evade is successful';
}
else if($wtype == 'Brawler'){
    $attributes['type'] = 'Brawler';
    $attributes['health'] = '90-100';
    $attributes['attack'] = '65-75';
    $attributes['defense'] = '40-50';
    $attributes['speed'] = '40-65';
    $attributes['evade'] = '0.3-0.35';
    $attributes['special'] = 'increased +10 defense when health is below 20%';
}

echo json_encode($attributes);
?&gt;
There are a few improvements that come to my mind for the given code:


you may want to return an status code for your JSON output instead of checking whether the result is an object. It would allow you to handle error messages and such in a more convenient manner.
as a minor improvement, you can use replaceWith() to replace the table body instead of removing it and then appending a new one to the table.
you don't have an error handler to your script... if you won't ever need it, that's cool, but it's always best to know when a script fails :)
to improve concatenation performance, you might want to use Array's join() method instead of doing += for each table row.
you're now removing all table bodies on the whole page, which could be kind of risky if you have more than one table there. Furthermore, the selector is extensively greedy, as jQuery has to find all table bodies on the whole page. It's better to use ID selectors when possible, as they are the fastest one to execute.
PHP-wise, you don't handle invalid $wtype, so if no condition is met, you won't know what went wrong, since nothing relevant will be returned


Enough of the theory, this is what I have in mind:

$.ajax({
                url: "get_attributes.php",
                type: "post",
                datatype: "json",
                data: {wtype: red_type},
                success: function(data) {
                    if (data["status"] == 200) {
                        var toAppend = [];
                        toAppend.push(
                            "&lt;tbody&gt;",
                            "&lt;tr&gt;&lt;/td&gt;&lt;td class=datalabel&gt;Type:&lt;/td&gt;&lt;td&gt;"+data['type']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Health:&lt;/td&gt;&lt;td&gt;"+data['health']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Attack:&lt;/td&gt;&lt;td&gt;"+data['attack']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Defense:&lt;/td&gt;&lt;td&gt;"+data['defense']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Speed:&lt;/td&gt;&lt;td&gt;"+data['speed']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Evade:&lt;/td&gt;&lt;td&gt;"+data['evade']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;tr&gt;&lt;td class=datalabel&gt;Special:&lt;/td&gt;&lt;td&gt;"+data['special']+"&lt;/td&gt;&lt;/tr&gt;",
                            "&lt;/tbody&gt;"
                        );
                        $("#red_form table tbody").replaceWith(toAppend.join(""));
                    } else {
                        alert('An error has occured. Please try again.');
                        console.log('Status: ' + data["status"] + ', message: ' + data["message"]);
                    }
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert('An error has occured. Please try again.');
                    console.log('ErrStatus: ' + textStatus + ', error: ' + errorThrown);
                }
            });


And the PHP:

&lt;?php
header("Content-Type: application/json");
$wtype = (isset($_POST['wtype']) ? $_POST['wtype'] : 'unknown');
$attributes = array('status' =&gt; 200, 'message' =&gt; 'ok', 'type' =&gt; $wtype);

switch ($wtype) {
    case 'Ninja':
        $attributes['health'] = '40-60';
        $attributes['attack'] = '60-70';
        $attributes['defense'] = '20-30';
        $attributes['speed'] = '90-100';
        $attributes['evade'] = '0.3-0.5';
        $attributes['special'] = 'There is a 5% chance of 2x attack';
        break;

    case 'Samurai':
        $attributes['health'] = '60-100';
        $attributes['attack'] = '75-80';
        $attributes['defense'] = '35-40';
        $attributes['speed'] = '60-80';
        $attributes['evade'] = '0.3-0.4';
        $attributes['special'] = '10% chance of restoring +10 health when evade is successful';
        break;

    case 'Brawler':
        $attributes['health'] = '90-100';
        $attributes['attack'] = '65-75';
        $attributes['defense'] = '40-50';
        $attributes['speed'] = '40-65';
        $attributes['evade'] = '0.3-0.35';
        $attributes['special'] = 'increased +10 defense when health is below 20%';
        break;

    default: $attributes['status'] = 400;
             $attributes['message'] = 'Invalid class info has been requested.';
}

echo json_encode($attributes);
?&gt;