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.