PHP 페이지 인 send.php가 있습니다.이 페이지는 내가 그 페이지로 갈 때 배열을 반향 출력합니다. 그러나 내가 그 페이지에 액세스 할 수있는 index.php에 아약스를 사용하려고하면 응답이 없습니다. 나는 그것이 작동하고 배열이 인쇄 브라우저에서 send.php로 이동합니다요청을 사용할 때 아약스 요청에서 응답이 없습니다.
이 내가
error_reporting(E_ALL);
ini_set('display_errors', 1);
$json = array(
"test" => null,
"success" => null,
"urls" => null,
);
$json = array("hi" => null, "success" => null);
$class = new test();
$json["success"] = true;
$json["hi"] = $class->_array;
echo json_encode($json);
class test{
public $_array = array();
public $urlPreArray;
public $sensoredArray;
function __construct(){
require_once('./mysqlDB.php'); //this causes nothing to be sent back
$cookieString = $_COOKIE['crUrl'];
$this->_array = explode(",", $cookieString);
}
}
send.php 에 접근하고있는 페이지이 내 인덱스 페이지
<html>
<head>
<script src="jquery1.11.js"></script>
<meta charset="utf-8">
<script>
function load(){
$.get("./php/send.php",
{
action:"displayUrlsNotes"
},
function(data, status){
console.log(status);
console.log(data);
}, "json");
console.log("end");
}
</script>
</head>
<body>
<button onclick='load();'>Click Me</button>
</body>
</html>
입니다 ,하지만 index.php에 가서 버튼을 누르면 ajax 요청은 successfuly하지만 아무 것도 보내지지 않습니다.
require_once ('./ mysqlDB.php');를 주석 처리하면 작동합니다. in send.php
나는 php에서 클래스를 사용하는 것에 익숙하지 않고 정확히 어떤 대답을 찾기 위해 google을 필요로하는지 확실히 모른다.
폴더 또는 index.php 경로 내에서 mysqlDB.php는 어디에 있습니까? –
index.php와 php라는 폴더가 있습니다. mysqlDB.php와 send.php는 PHP 폴더에 있습니다. 나는 mysqlDB.php를 index.php와 같은 폴더에 넣었으므로 문제가 해결되지 않았기 때문에 디렉토리 문제라고 생각하지 않는다. 또한 그것이 문제라면 send.php로 갈 때 오류가 발생할 것이라고 생각합니다. – Megan