0
JS에 객체를 전달하려고합니다 (일부 jQuery가 포함됨). :)Javascript - 종속성 삽입 및 약속
promise.success
함수가 실행되면 FlappyBarHelper.getUserPropertyCount()
메서드를 호출하고 싶습니다. I가 this.FlappyBarHelper
전달 시도했다 :
return $.ajax({
type: "GET",
url: 'get-the-score',
flappy: this.FlappyBarHelper,
});
하지만 여전히 promise.success
내 전체 코드에서 정의되지 않은 flappy
을 만드는 것은 ($ 아약스]의 문서에서
function Rating(FlappyBarHelper) {
this.FlappyBarHelper = FlappyBarHelper;
}
Rating.prototype.attachRaty = function(property_id)
{
var promise = this.getPropertyScoreAjax(property_id);
promise.success(function (data) {
$('#'+property_id).raty({
click: function (score, evt) {
$.ajax({
type: "GET",
url: '/set-the-score',
})
.done(function (msg) {
$('#extruderTop').openMbExtruder(true);
//**** FlappyBarHelper is undefined at this point ****///
FlappyBarHelper.getUserPropertyCount('.flap');
});
}
});
});
};
Rating.prototype.getPropertyScoreAjax = function(property_id)
{
return $.ajax({
type: "GET",
url: 'get-the-score',
});
}
꽤 교과서 대답. 자세한 설명 주셔서 감사합니다. 나는 또한 '성공 대 완료'라는 차이점을 읽었습니다. :) – Kiksy
당신을 환영합니다! – Feugy