난 다음 문자열 여전히편집 됨 OK JSON 응답 (200)을 볼 수는 있지만
([{"data":{"Rate":"","RoleA":"Student","NameA":"student","RoleB":"Tutor","NameB":"tutorB","Give":"0","Get":"1","Accept":"0"}}]);
내가
http://api.jquery.com/jQuery.ajax/에서 읽고
하지만 내가 잘못하지 않은 경우 확실하지를 얻을 수 있습니다 parsererror 반환 할 수 있습니다.
이
내가는 JSON 문자열을 찾을 수 있으며 정상 보이는, 내 코드 크롬에서 $.ajax({
type: 'GET',
dataType: 'jsonp',
jsonpCallback: 'jsoncallback',
data:
{
nameB: nameB,
roleB: roleB,
get123: get123,
accept: accept
},
url: 'http://mydomain.com/check.php?callback=?',
success: function(data){
alert(data[0].data.RoleA);
//alert("ABC");
//if ($("#role").text() == "Tutor")
//{
// window.location.href='tutor_home.html';
//}
//else
//{
// window.location.href='student_home.html';
//}
},
error: function(jqXHR, textStatus){
alert("Request failed: " + textStatus);
}
});
입니다. 그러나, 그것은 성공 메시지를 경고하지 않고 대신 parsererror 오류를 경고합니다. 감사합니다
내가 확실하지 않다
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Content-type: application/json");
include('mysqlConfig.php');
$nameB = $_GET["nameB"];
$roleB = $_GET["roleB"];
$get = $_GET["get123"];
$accept = $_GET["accept"];
$sql="SELECT * FROM tbl_rating WHERE NameB='$nameB' and RoleB='$roleB' and Get='$get' and Accept='$accept'";
$result=mysql_query($sql);
$rows = array();
//retrieve and print every record
while($r = mysql_fetch_assoc($result)){
// $rows[] = $r; has the same effect, without the superfluous data attribute
$rows[] = array('data' => $r);
}
// now all the rows have been fetched, it can be encoded
//echo json_encode($rows);
$data = json_encode($rows);
echo $_GET['jsoncallback'] . '(' . $data . ');';
?>
내 PHP는 왜 요청 URL 다음과 같이 URL은 다음과 같습니다 http://mydomain.com/check.php?callback=jsoncallback&nameB=tutorB&roleB=Tutor&get123=1&accept=0&_=1363710513593
나는 그것이 무엇 확실하지 오전 마지막 매개 변수 &_=1363710513593
를?
하지만 위의 문자열은 JQuery와 버전에 관련된 않습니다
을 반환 할 수 있습니다? jquery-1.9.1.min.js를 사용했습니다.
시도한 내용은 무엇입니까? 어떤 오류가 발생 했습니까? (우리가 당신을 위해 숙제를 할 것을 기대하지 마십시오 ...) – Martijn
GET에서 POST로 유형을 변경하려고 시도하고 다른 URL을 변경하려고 시도했으며 모두 모두 "오류가 발생했습니다." – HUNG
이 링크의 응답을 표시 할 수 있습니까? http : //mydomain.com/check.php? nameB = tutorB & roleB = 교사 & get123 = 1 & accept = 0 & jsoncallback = mycallback' – vittore