用PHP进行Ajax调用

Im using $.ajax in javascript. I need to get the response from php file. The code in javascript is -

var datavalues = {
                 a: 12,
                 b: 54
                 };


$.ajax({
       type: "POST",
       url: 'http://localhost/example/test.php',
       data: datavalues,
       success: function(response)
       {
       console.log(response);
       $('#label').html(response);
       var responsevalue = response;
       }
       });

and the code in php file is -

$bt = rand(0, 99);
$bt = intval($bt);
echo $bt;

The issue is that it shows the value in the label but value is not coming fine in the responsevalue variable. I need integer value in the responsevalue variable.

Output of console.log(response); statement is -

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
</head>
<body>
</body>
</html>68<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
</head>
<body>
</body>
</html>

Here 68 should be the value of responsevalue variable.

I hope you are not confused with the above code.

Use jquery param

var datavalues = {
                 a: 12,
                 b: 54
                 };


$.ajax({
       type: "POST",
       url: 'http://localhost/example/test.php',
       data: $.param(datavalues),
       success: function(response)
       {
       console.log(response);
       $('#label').html(response);
       var responsevalue = response;
       }
       });

in PHP file echo $_POST['a'];

The answer is given by @ceejayoz in the comments. For reference Im posting his answer here

"@pareza If that's the response, your http://localhost/example/test.php does more than just echo $bt;. You need to stop it from outputting all that HTML around the value you want."