페이지에서 jquery의 $ .post 함수를 여러 번 사용해야합니다. 또한 필터링 목적으로 post 메서드에서 반환 된 데이터를 사용해야합니다. 그래서 저는 다음과 같이 post 함수를 넣었습니다 :jquery chunk에서 함수를 실행하는 방법
$(document).ready(function(){
function loadData(url){
$.post(url,function(data){
var $data = data;
});
}
var raw = loadData(page01.php).filter("#someId").html();
$("#content").html(raw);
var raw = loadData(page02.php).filter("#anotherId").html();
$("#content2").html(raw);
});
그러나 작동하지 않습니다. 위의 코드를 수정하면 도움이 될 것입니다. 감사합니다
의미 :
코드를 다음과 같이 보일 것인가? – j08691
불완전한 질문이지만 http://stackoverflow.com/questions/12475269/variable-doesnt-get-returned-from-ajax-function (및 비슷한 것)과 중복되는 것으로 보입니다. –
함수가 반환되지 않습니다. 아약스는 비동기입니다. – adeneo