나는 onChangeMonthYear에 의해 시작된 함수에서 얻은 데이터를 beforeShowDay에 의해 시작된 함수로 전달하려고합니다. 나는 test.php에서 얻은 데이터를 외부에서 선언 된 변수에 할당하는 것과 같이 여러 가지 방법을 시도했지만 아무 소용이 없었다. 그래서 내가 한 것은 test.php에서 가져온 데이터로 텍스트 필드를 업데이트하고 beforeShowDay의 함수에 거기에서 데이터를 가져 오기를 요청하는 것입니다. 여기 내 코드의 일부입니다.jquery datepicker는 한 함수에서 다른 함수로 변수를 전달합니다.
$(document).ready(function() {
$('#datepicker').datepicker({dateFormat: 'dd-mm-yy', currentText: 'Now', changeMonth: true, changeYear: true, altField: '#alternate', altFormat: 'DD, d MM, yy', onSelect: function(dateText, inst) {},
onChangeMonthYear: function(year,month,inst){
$.post("test.php", {action: "TEST", month: month, year: year},
function (data){
$("#datafromphp").val(data);
}
,"html");
},
beforeShowDay: function (date){
var getdatafromphp= $("#datafromphp").val();
}
});
});
확실히 더 좋은 방법이 있습니다.
당신은 당신이 "외부에 있지만 아무 소용이 선언 된 변수에"데이터를 할당하려고했다 : 그래서, 당신은 이런 식으로 뭔가를 할 수 있습니까? beforeShowDay의 – Exupery
함수는 가져 오지 않습니다. 비어 있습니다. 적어도 그것은 함수가 생각하는 것입니다. 설명 william에 대해 감사합니다. – imin