I am trying to extract data from mysql in php and return it in json format to a controller (angular).
While json is being created, some unwanted line appears, due to which I get an error when moving json.
Below is my PHP code:
$json_response = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $row_array["name"] = $row["name"]; $row_array["quantity"] = $row["quantity"]; array_push($json_response,$row_array); } echo json_encode($json_response);
And the following console output after printing json (the console is in the controller):
{itemData:{"data":[{"name":"item1","quantity":"10"},{"name":"item2","quantity":"20"},{"name":"item3","quantity":"25"}] <script type="text/javascript" src="http://stats.hosting24.com/count.php"></script> }}
There is json above the selected part, due to which an error occurs.
Please help me solve the problem.
source share