当我回显 $jsonstring 时,似乎整个空白 html 页面与我请求的对象一起发送(从 PHP 到 Javascript)。这里到处都是超级新的,所以我不明白为什么。
我的PHP代码:
<?php
//ini_set('display_errors', '1');
//ini_set('error_reporting', E_ALL);
require "localdbcxn.php";
$encoded = file_get_contents('php://input');
$decoded = json_decode($encoded, true);
$email = $decoded['email'];
$password = $decoded['password'];
$identify = mysql_query("SELECT UserId FROM users WHERE UserEmail='$email' AND UserPassword='$password'");
$numrows = mysql_num_rows($identify);
$row = mysql_fetch_assoc($identify);
$userid = $row['UserId'];
$sessionid = mt_rand(1111111111111111,9999999999999999);
$sessionkey = mt_rand(1111111111111111,9999999999999999);
$logindate = date("Y-m-d H:i:s");
$login = "INSERT INTO mobileSession (UserId, SessionId, SessionKey, BeginDate) VALUES('$userid','$sessionid','$sessionkey','$logindate') ON DUPLICATE KEY UPDATE SessionId='$sessionid', SessionKey='$sessionkey', BeginDate='$logindate' ";
if ($numrows == 1) {
mysql_query($login);
$session = array('UserId'=>$userid,'SessionId'=>$sessionid);
$jsonstring = json_encode($session);
echo $jsonstring;
}
?>
这是控制台(日志)显示的内容:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>{"UserId":"33","SessionId":8207219793564744}
从 UserID 到 ...4744 是正确的,但是谁能帮我理解为什么要回显 html 代码?在我有限的经验中,我以前没有见过这个,并且觉得我做错了什么。
谢谢!