<?php
include_once('db.php');
$location = $_POST['location'];
$doctor = $_POST['doctor'];
$patient_id = $_POST['patient_id'];
if(($location != "") && ($doctor != "")) {
$sql = "select Name,Age,Gest_age,Weight from rop_form where Location = '".$location."' and Doctor = '".$doctor."' and Patient_id = '".$patient_id."'";
$result = mysql_query($sql);
$myresult = "";
while($row = mysql_fetch_array($result)) {
$myresult1['Patient_id'] = 'R'.$patient_id;
$myresult1['Name'] = $row['Name'];
$myresult1['Age'] = $row['Age'];
$myresult1['Weight'] = $row['Weight'];
$myresult1['Gest_age'] = $row['Gest_age'];
}
$myresult = json_encode($myresult1);
}
else {
$myresult .= "";
}
echo $myresult;
?>
이것은 내 PHP 코드입니다.jQuery 배열 문제
이것은 jQuery 코드입니다.
$("#patient_id").change(function() {
$.post("/diabetes/patient_detail_change.php",{ location:$("#location").val(),doctor:$("#doctor").val(),patient_id:$("#patient_id").val()} ,function(json_data) {
alert(json_data);
//var my_json = //{"Patient_id":"R00020","Name":"admin","Age":"12","Weight":"67","Gest_age":"2"//};
$.each(json_data, function(key,value) {
alert(key + ': ' + value);
if(key == 'Name'){ $("#name").val(value); }
if(key == 'Age'){ $("#age").val(value); }
if(key == 'Weight'){ $("#ropweight").val(value); }
if(key == 'Gest_age'){ $("#gest_age").val(value); }
});
});
});
alert (json_data); JQuery와
그러나 같은 존재하는 .each 루프 문에 필요한 fomat입니다 제대로
{"Patient_id":"R00006","Name":"admin","Age":"12","Weight":"67","Gest_age":"2"}
등이 줄을 인쇄 : alert(key + ': ' + value);
는 Patient_id처럼 인쇄되지 않습니다 : R00006 모두는 0:{ 1:P 2:a 3:t 4:i
같은 인쇄 나누었다 .. 무엇이 문제일까요?
가장 적합한 답을 수락하는 것을 잊지 마십시오. –