我有一个未知的情况,AJAX 请求没有到达 PHP 服务器。
Chrome 浏览器中没有错误代码,但没有到达 PHP GET 方法。
在我的代码中
function GetLectureData(SID){
$.ajax({
url: "test.php",
dataType: "jsonp",
jsonpCallback: 'callback',
data: {"SID_key": SID},
Type: 'GET',
success: function(data) {
console.log('DB정보 접근성공- ', data);
if(data != null) {
for(var i=0; i<data.length;i++)
{
var flags=true;
lectrueInfo=data[i].classroom.split('-');
Lecture[i] = lectrueInfo[1];
Lecture[i] = Lecture[i].slice(1,4)+"호";
console.log(Lecture[i]+" "+count);
count++;
if(typeof Lecture[i]== "undefined")
{
break;
}
for(var j=0;j<i; j++)
{
if(Lecture[i]==Lecture[j])
{
flags = false;
}
}
if(flags == true)
{
Create(Lecture[i]);
}
}
}
},
error: function(xhr) {
console.log('실패 - ', xhr);
}
});
}
<?php
header('Content-Type: application/javascript;charset=UTF-8');
$user = 'hyumini';
$pw = 'hyu(e)mini';
$db = 'hyumini';
$host ='localhost';
$port = 3306;
$table = 'LectureSchedule';
$my_db = new mysqli($host,$user,$pw,$db,$port);
mysqli_query($my_db,"set names utf8");
if ( mysqli_connect_errno() ) {
echo mysqli_connect_errno();
exit;
}
$q=$_GET["SID_key"];
$callback = $_REQUEST['callback'];
$return_array = array();
$count = 0;
$rs = mysqli_query($my_db, "select DISTINCT LectureSchedule.classroom
from ConnectLecture JOIN LectureSchedule
ON ConnectLecture.SID = $q AND ConnectLecture.lectureID = LectureSchedule.lectureID");
while($data = mysqli_fetch_array($rs))
{
$array[] = $data;
}
$my_db->close();
$json_val = json_encode($array);
echo $callback."(".$json_val.")";
?>
我真的很想知道为什么会在这种情况下发生这种情况。