0
크롬 관리자의 test.php에서 보낸 헤더를 보면 action : startjson
이라고 표시되지만이 변수를 검색 할 수 없습니다. $_GET['action']
, 배열이 비어 있습니다.Get ajax가 작동하지 않는다
test.php :
<body>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript">
$(document).ready(function(){
$("#testjson").click(function(e){
startJsonSession();
return false;
});
function startJsonSession(){
$.ajax({
url: "test2.php?action=startjson",
cache: false,
dataType: "json",
complete: function(data) {
username = data.username;
alert(username);
}
});
}
});
</script>
<button id="testjson">
toto
</button>
</body>
test2.php :
<?php
if ($_GET['action'] == "startjson") {
startjsonSession();
}
function startjsonSession() {
$items = '';
print json_encode(array(
"username" => "bob",
"items" => array(
"item1" => "sandwich",
"item2" => "applejuice"
)
));
}
요청 상태는 어떻습니까? – tymeJV