Let's me describe what I'm working on before I ask my question:
I'm building a clinic queuing management system, in part of the system, I have three files here, they are index.php, test.php and test.js respectively.
==> test.js will send request to test.php to get 2 JSON data, there are $queueNumber and $room stored in test.php. After that will append a new in index.php and under that will append 2 which shows $queueNumber and $room.
==> test.php produce a ticket number and a room number stored in $queueNumber and $room respectively.
==> index.php is just a file that contain 2 table, 1 table for header and 1 table to show the ticket number and room number.
The following is code of index.php
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>And San King EMR</title>
</head>
<body>
<table width="95%" align="center" border="1">
<tr>
<th width="50%" style="font-size:40px;">Number</th>
<th width="50%" style="font-size:40px;">Office</th>
</tr>
</table>
<table width="95%" align="center" border="1" id="queueDisplay">
</table>
<script src="/system/javascript/jquery.js"></script>
<script src="test.js"></script>
</body>
</html>
the following is the code of test.js
$(document).ready(function(){
$.ajax({
url: "test.php",
data:"";
dataType: "json",
success : function (data) {
x=data.queueNumber;
y=data.room;
alert('The queue number is '+ x +' and the room is '+ y);
},
});
});
the following is code of test.php
<?php
include("connect.php");
$sql = mysql_query("SELECT * FROM queue WHERE status='calling' ORDER BY ID ASC LIMIT 1");
$row = mysql_fetch_array($sql);
$queueNumber = $row['queueNumber'];
$room = $row['room'];
$json = array("$queueNumber","$room");
echo json_encode($json);
?>
Question: When I try to run index.php, I get the following error message, I should I solve this error message?
error syntax error: JSON.parse: unexpected character at line 1 column 1 of the JSON data