언어&플랫폼/Html/JQuery
[jquery] ajax json 동기 호출
cozyboy
2013. 10. 10. 11:47
function getRemote() {
return $.ajax({
type: "GET",
url: remote_url,
async: false,
}).responseText;
}
위의 것은 그냥 그대로 사용 하지 않다. json object로 변경 해줘야 한다.
var jsonObject = JSON.parse(getRemote());
ajax는 기본이 동기화 호출이라, 실행하고 기다리지 않고 바로 종료된다. 그래서
ajax 호출 후 다른 함수를 호출 시 실행이 돼지 않는다.??
참고 :
http://stackoverflow.com/questions/6685249/jquery-performing-synchronous-ajax-requests -비동기 호출
http://blog.outsider.ne.kr/257 - resposeText를 json object로 변환