用Jquery的$.get方法遇见的问题
$(document).ready(function() {
var html = "<div class='tabbable tabs-left'><ul class='nav nav-tabs'>";
var html_institute = '';
var html_subject = '';
$.get("@{ViewResource.viewInstitute}",function(institute_data){
$.each(institute_data,function(commentIndex, comment){
html_institute += "<li><a href='#tab"+commentIndex+ "'data-toggle='tab'>"+institute_data[commentIndex]+"</a></li>";
var value = institute_data[commentIndex];
//alert(institute_data[commentIndex]);
//alert(html_institute);
//alert(1);---------------------------------1
$.get("@{ViewResource.viewSubject}",{
institute : value
},function(subject_data){
// alert(commentIndex);
// alert(value);
alert(html_subject);
html_subject += "<div class='tab-pane' id='tab"+commentIndex+"'>";
$.each(subject_data,function(subject_commentIndex, subject_comment){
//alert(subject_data[subject_commentIndex].subject);
html_subject += "<p>"+subject_data[subject_commentIndex].subject+"</p>";
});
html_subject += "</div>"
//alert(html_subject);
});
});
//html += html_institute + "</ul>" + "<div class='tab-content'>" + html_subject +"</div></div>";
//alert(html)
},"json");
});是一个ajax的get请求过来一个数据后,然后把这个数据当做参数,在异步一次获取一个新的信息!但是发现了一个问题,就是第一个each循环会先直接执行完了,然后再执行第二个each。但是在1处加上alert这句后,程序就正常执行了!这是为什么?求大神解答!
...全文
相关推荐
jQuery Ajax之$.get()方法和$.post()方法
注意:$.get()和$.post()方法是jQuery中的全局函数。前面讲到的load()方式是对jQuery对象进行操作的。 1、 $.get()方法 $.get()方法使用GET方式来进行异步请求。 它的语法结构为: $.get( url [, data] [, callback] [, type] ) $.get()方法参数解释如下表: 参数名称 类 型 说 明 url String 请求的HTML页的URL地址 data(可选) Object 发送至服务器的key/value数据会作为QueryString附加到请求URL中 callback(可选)
jQuery使用$.get()方法从服务器文件载入数据实例
主要介绍了jQuery使用$.get()方法从服务器文件载入数据,较为简单的分析了jQuery中get方法的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下
解决JQurey跨域问题$.get|$.post|$.getJSON等等统统可跨域
解决JQurey跨域问题$.get|$.post|$.getJSON等等统统可跨域
学习jQuery中的Ajax——$.get()方法
NULL 博文链接:https://xa-zbl.iteye.com/blog/552797
jQuery Ajax 实例代码 ($.ajax、$.post、$.get)
下面小编就为大家带来一篇jQuery Ajax 实例代码 ($.ajax、$.post、$.get)。小编觉得挺不错的,现在分享给大家,也给大家做个参考



