私は使っています:echo json_encode($ Response);連想配列をJQuery Ajaxに送り返す。各IDキーの値を読み取ろうとすると、私は未定義の値を取得します。私はそう間違ってやっているかを把握助けて...事前に感謝JQueryから 'echo json_encode()'を読む正しい方法
私のPHPコードしてください:
$Stuff = 'Hello world';
$Success = true;
$Content = $Stuff;
$Response = array('Success' => $Success, 'Content' => $Content);
echo json_encode($Response);
# #
私のJSコード:
var sFirstName = $('#student_first_name').attr('value');
$.ajax({
type: "GET",
url: "../pgs/UpdateEditAStudent.php",
data: "FirstName="+ sFirstName ,
//The below code will give me: {"Success":true,"Content":"Hello world"}
success: function(data){$("#Ajax_response").html(data);}
//The popup window will show me "Undefined"
//and: {"Success":true,"Content":"Hello world"}
success: function(data){$("#Ajax_response").html(data); alert(data.Content);}
});
ような何か? – Niklas