2013-06-21 3 views
0

jquery를 사용하여 아약스 호출에서 응답을 다시 표시하려고합니다. 내 문제는 아래에 표시된 콜백 메서드를 올바르게 사용하는 방법을 모르겠다는 것입니다.jquery 콜백 메서드를 사용하는 방법

// Ajax Method 

loadAjaxWindow: function (url, callback, async, errorCallback, cache, type, data) { 
     success: function (data, textStatus, xhr) { 
     callback(data); 
     }, 
} 

내가 해봤 경고가 표시되지 않지만 다음

많은 감사

var data = "my data to post"; 

.loadAjaxWindow(url, jr.dialog(data), true, 
     function(xhr, textStatus, errorThrown) { 
      // stuff 
     }, 
     true, 'post', data); 

방법은 다음과 같습니다?

var myCallBack = function(obj) { 
     alert(""); 
}; 

.ajax.loadJson(url, myCallBack, 
    true, 
    function(xhr, textStatus, errorThrown) { 
     // stuff 
    }, 
    true, 
    'post', 
    JSON.stringify(data) 
); 

답변

0

여기 콜백이다 AJAX 성공 콜백을 호출 할 때 호출되는 함수 ... 일례되도록

..

var callback=function(obj){ 
     console.log(obj); 
     jr.dialog(obj) //jr ?? 
     //do yourstuff with ajax returned data which is as obj here 
}; 

loadAjaxWindow: function (url, callback, async, errorCallback, cache, type, data) { 
    success: function (data, textStatus, xhr) { 
    callback(data); 
    }, 
} 

그래서 이것은 datas 회수를 기록한다 콘솔에 체크인하면 아약스 호출로

+0

내 시도가있는 이상 실패를 참조 할 원하는 서버에 의해 반환 된 값이, 당신이하는 데 사용할 수 있습니다

.loadAjaxWindow(url, jr.dialog(data), true, function(data) { // use data to do further processing, it is the value returned by server }, true, 'post', data); 

해야한다 . –

0

콜백 구문이 잘못, 그것은 data 당신이

관련 문제