我必须在页面中多次使用jQuery的$ .post函数。此外,我必须使用post方法返回的数据进行过滤。所以我把这样的帖子功能:如何在jquery块下执行函数
$(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(和许多类似的)的副本 –
函数不返回任何东西,即使它做到了,ajax也是异步的。 – adeneo