2010-06-22 5 views
0
function symbol_handler(){ 
    fp.getForm().submit({ 
    url:'/index.php/ajax/test_function', 
     success:function(resp){ 
     //how would i access attributes of the json object? 
    } 
}); 

편집 : 여기에 해당하는 PHP 컨트롤러가 있습니다. extjs 3.2.1 API 따른extjs json decode

function test_function(){ 
$array = array(
    'success' => 'true', 
    'msg' => 'testing testing testing' 
    ); 
    echo json_encode($array); 

}

function symbol_handler(){ 
    fp.getForm().submit({ 
     url:'/index.php/ajax/test_function', 
     success:function(resp){ 
      console.log(resp); 
     } 
    }); 
    } 

와 CONSOLE.LOG (RESP)의

출력 ...

Object 
activeAction: null 
bodyStyle: "padding: 6px" 
buttons: Array (1) 
0: Object 
handler: function symbol_handler(){ 
hideParent: true 
minWidth: 75 
removeMode: "container" 
text: "GO" 
__proto__: Object 
length: 1 
__proto__: Array 
el: Object 
events: Object 
frame: true 
height: 100 
id: "ext-gen48" 
items: Object 
labelWidth: 40 
title: "Exercising textfields" 
width: 300 
__proto__: Object 

감사 브랜든

답변

2

success -callback의 서명은 form가에 대한 참조입니다 function(form, action)입니다 양식이 제출되고 action이 제출 된 조치 오브젝트입니다. Ext.form.Action.Submit 또는 Ext.form.Action.DirectSubmit의 인스턴스 (Ext.direct을 사용했는지 여부에 따라 다름)입니다. action 개체는 많은 속성에 액세스 할 수 있으며 그 중 디코드 된 응답 개체가 포함 된 result 속성이 있습니다. 따라서 ExtJS 코드는 다음과 같아야합니다.

function symbol_handler(){ 
    fp.getForm().submit({ 
     url:'/index.php/ajax/test_function', 
     success:function(form, action){ 
      console.log(action.result); 
     } 
    }); 
} 
1

(나는 wh 몰라.

  1. 형태 : 당신이)를 사용하는 무형 문화 유산 버전은 성공의 기능은 다음과 같은 매개 변수 전달 Ext.form.BasicForm 작업을 요청 양식 을
  2. 조치 : Ext.form.Action 액션 수업. 의 결과 속성은 사용자 정의 후 처리를 검사 할 수 있습니다.

시도는 함수에 전달되는 것을 인수 알기 위해 성공 기능에 다음을 추가합니다 :

console.log(arguments); 
관련 문제