많은 질문을 읽었지만 특정 문제를 발견 할 수없는 것 같습니다 가져 오기 배열을 반환하는 PHP 스크립트가 있으며이를 JSON으로 인코딩합니다. 나는 (내가 그것에 대해 뭔가를 읽을 수는 있지만 단서를 가지고하지 않은 경우)PHP는 JSON 객체를 jQuery 아약스 호출로 반환합니다. 이제 무엇을할까요?
PHP의
if (mysql_num_rows($pquery) == 1) {
$result = mysql_fetch_assoc($pquery);
echo json_encode($result);
}
을 내 PHP 스크립트에는 헤더가없는 jQuery를
$('#c_search').submit(function(){
data = ($(this).serialize());
$.ajax({
url: 'actions/get_company.php',
type: 'POST',
data: data,
cache: false,
success: function(text){
alert (text);
alert(text[1]); // not right!
alert(text.company[0]);// not right!
}
}).error(function(){
alert('error');
})
return false;
})
내가 돌아올 텍스트 :
{"id":"167","company":"ZEN","street":"1 S Congress Ave","email":"[email protected]","state":"TX","zip":"78704","phone":"512-555-1212"}
어떻게 적절하게 처리하여 각 개별 조각을 자체 변수에 배치 할 수 있습니까?
고정되었습니다. 감사합니다 모두 ... 스택이 허용하는 6 분 안에 확인합니다. –