에서 콜백와 지역 변수를 조작 여기에 jQuery로 내 코드입니다 : 응답JS
function check_hotel_exists(value, col)
{
var url = base_url + 'ajax/checkuniquehotel';
var response = false;
$.get(url, {hotelname:value}, function(data){
if (data === 'true') response = true;
});
alert((response) ? 'Hotel is Not Existing' : 'Hotel Exists');
return [response, "That hotel already exists"];
}
값은 변경되지 않습니다.
get 함수에서 콜백으로 응답 값을 변경하려면 어떻게해야합니까? 'true'또는 'false'인 서버 응답에서 변수 데이터를 기대합니다.
어떤 도움
을 감상 할 수있다. :
이 아무튼를 콜백 매개 변수로 수신 기능, 즉 그 차례에
check_hotel_exists
기능 비동기 일하지 마라. Ajax 호출은 비동기식입니다. –이것은 확실히 작동하지 않습니다. – Rippo