最初一切正常,直到IT人员更换服务器 我用ajax调用php文件从数据库中获取数据。现在我得到一个错误 PHP注意:未定义的索引:jsoncallback
header('Content-Type: application/json');
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM users";
$result = mysqli_query($conn, $sql);
$records = array();
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$records[] = $row;
}
}
mysqli_close($conn);
echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');';
====
$.ajax({
url: 'http://test.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
async: false,
timeout: 5000,
success: function(data, status)
{
},
error: function(){}
});