在 Jquery 中的 each() 中使用 get() 并在客户端本身执行操作
use get() inside each() in Jquery and perform action in client side itself
我想在 each() 函数中使用 get() 进行此 Ajax 调用,以从文件中获取数据,循环遍历 each()。
这是我的一段代码:
jQuery.each(html_files, function(index,post_html){
jQuery.get(post_html, function(data){
// do action
});
});
这里,html_files是一个数组,包含html个文件的列表。
但是,我只能获取第一个文件的数据。
我如何同步执行它。
提前致谢!
jQuery.each(html_files, function(index,post_html){
jQuery.ajax({
type:get,
url:post_html, //or the url to fetch data
success:function(data){
alert(data);
}
});
});
看看这个
我想在 each() 函数中使用 get() 进行此 Ajax 调用,以从文件中获取数据,循环遍历 each()。
这是我的一段代码:
jQuery.each(html_files, function(index,post_html){
jQuery.get(post_html, function(data){
// do action
});
});
这里,html_files是一个数组,包含html个文件的列表。
但是,我只能获取第一个文件的数据。 我如何同步执行它。
提前致谢!
jQuery.each(html_files, function(index,post_html){
jQuery.ajax({
type:get,
url:post_html, //or the url to fetch data
success:function(data){
alert(data);
}
});
});
看看这个