jQuery 콜백 함수가 있습니다. 그 함수에서는 더 높은 범위에있는 변수의 값을 변경하려고하지만 어떤 이유로 그것이 그렇게하지 않습니다. 여기 코드는 다음과 같습니다jQuery가 콜백에서 상위 범위의 객체를 설정하지 않습니다.
function add() {
var returnedData = {
my_id: 0
};
$.post("add_event.php", { event : toSendText }, function(data) {
returnedData.my_id = 5;
}, "json");
if(add_page == true){
alert(returnedData.my_id);
window.open('content-list.php?cal_id=');
}
}