MagicSuggest失败了php文件

Hi i'm using Magicsuggest library Here's a link. So i encounter with this errors when i try to connect to mysql

Uncaught SyntaxError: Unexpected end of input

The tag table contain two column the id and name of the tag. So how can i fix this error. Thanks for help. Here it's my php file

<?php

$con=mysqli_connect("localhost",'root', '','freelancer');

$query = "SELECT * FROM tag";

$result = mysqli_query($con,$query);

$rows = array();
while($r = mysqli_fetch_array($result)) {
    $rows[] = $r;
}
echo json_encode($rows);

?>

Here is my JavaScript:

$(document).ready(function() {
    $('#magicsuggest').magicSuggest({
        placeholder: 'Các kỹ năng yêu cầu',
        allowDuplicates: false,
        maxSelection: 2,
        data: '/valid/tags.php'
    });
});