$ .ajax不发布我的变量?

var code = $.cookie('code');
$.ajax({
    type: "POST",
    url: "ajax/loadData.php",
    data: { 'code': code },
    dataType: "json",
    success: function(data) {
        console.log(data.coins);
    },
    error: function(emsg) {
        alert(emsg.responseText);
    }
});

Basically it shows the response text and within it, it has: Notice: Undefined index: code in D:\wamp\www\ajax\loadData.php on line 3 and I'm unsure why this is so, so if anyone could help me clear it up, I'd be grateful.

loadData.php:

<?php
include '../inc/_db.php';
$code = $_POST['code'];
$query = mysqli_query($db, "SELECT * FROM data WHERE code='$code'");
$rows = array();
while($row = mysqli_fetch_array($query)) {
    $rows[] = $row;
}
echo json_encode($rows);
?>

Try setting the data parameter to proper json

$.ajax({
    type: "POST",
    url: "ajax/loadData.php",
    data: { 'code': code  },
    dataType: "json",
    success: function(data) {
        console.log(data);
    },
    error: function(emsg) {
        alert(emsg.responseText);
    }
});

The error is stating that $_POST['code'] is not set, therefor the first place to look is where you set it.