ajax工作中使用模板

前端之家收集整理的这篇文章主要介绍了ajax工作中使用模板前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!-- 生成课件 --> <action name="createCourseware" class="coursewareManagementAction" method="createCourseware"> <result name="ajax" type="jsonmessage"> <param name="message">message</param> </result> </action> $.ajax({ url: "<s:url value='/childmanagement/changeChildUserIdInSession.action'/>",type: "post",async:true,data:{userId:userId},dataType: "json",contentType:"application/x-www-form-urlencoded; charset=UTF-8",// success: function( rtnValue ){ if(rtnValue.message == "true" ){ // location.reload(true); // $("#child_link").find("span").html(userName); $("#child_link").find("span").attr("childId",userId); } },error: function(reqObj,strError,strObj){ alert("程序出现错误:" + strError); } }); //load方法得替代实现 $(".ranking_refresh_btn").click(function(){ var schoolClassId = '${schoolClassId}'; $.ajax({ url: "<c:url value='/personalindex/getStudyTimeList.action'/>",data:{schoolClassId:schoolClassId},success: function( response ){ $(".studyTimeRank").empty(); $(".studyTimeRank").append(response); },strObj){ //未做处理 } }); }); function showFindBug(){ art.dialog.open("/customerservice/showFindBugDialog.action",{ id: 'FeedBackDialog',title: '',width:540,height:390,lock: true }); } -------------------------------------------------ajax 返回json对象------------------------------------------------ <!-- ajax 获取课表内容 --> <action name="ajaxGetTiMetableContent" class="tiMetableAction" method="ajaxGetTiMetableContent"> <result name="ajax" type="json"> <param name="include">tiMetableContentList</param> </result> </action> $("#weekSelect").change(function(){ var yearWeekString = $(this).val(); $.ajax({ url: "<s:url value='/tiMetable/ajaxGetTiMetableContent.action'/>",data:{yearWeekString:yearWeekString},//防止中文乱码 success: function( rtnValue ){ $("td[id]").empty(); $(rtnValue).each(function(){ var content = $("#oneContentSample").clone(); var dayOfWeekCourseIndex = this.dayOfWeekCourseIndexString; var classScheduleId = this.id; if( classScheduleId == null || classScheduleId == "" ){ content.find(".oneContentShow").hide(); } else{ content.attr("schoolClassId",this.schoolClassId); content.attr("classScheduleId",classScheduleId); var displayName = classDisplayName(this.grade,this.schoolClassName); //Content用于显示 content.find(".oneContentShow").children("span").html(displayName); //[备课]or[授课] if( this.preparedLesson == true ){ //已经备课了,直接授课 var descObj = content.find(".oneContentShow").find("span.teach"); descObj.html("授课"); descObj.attr("state","lesson"); } //Content用于编辑 content.find(".oneContentEdit>div>span").html(displayName); } content.show(); content.attr("id",dayOfWeekCourseIndex+"Div"); $("#"+dayOfWeekCourseIndex).append(content); }); },strObj){ alert("程序出现错误:" + strError); } }); }); ================================ ================================ <!-- ajax 课表选择班级 --> <action name="ajaxCourseSelectSchoolClass" class="tiMetableAction" method="ajaxCourseSelectSchoolClass"> <result name="ajax" type="json"> <param name="include">tiMetableContentVo</param> </result> </action> //选择班级[确认] $(".buttonConfirm").die().live("click",function(){ var classScheduleId = lastContentObj.attr("classScheduleId"); var schoolClassId = $("#selectClassId").val(); var yearWeekString = $("#weekSelect").val(); var dayOfWeekCourseIndexString = lastContentObj.parent("td").attr("id"); var forceUpdate = $("#tiMetable_selectClass").find(".centerClassDialog").children(".showMessages").is(":hidden") ? false : true; $.ajax({ url: "<s:url value='/tiMetable/ajaxCourseSelectSchoolClass.action'/>",data:{classScheduleId:classScheduleId,schoolClassId:schoolClassId,yearWeekString:yearWeekString,dayOfWeekCourseIndexString:dayOfWeekCourseIndexString,forceUpdate:forceUpdate},//防止中文乱码 success: function( rtnValue ){ if( rtnValue.message == null || rtnValue.message =="" ){ lastContentObj.attr("classScheduleId",rtnValue.classScheduleId); lastContentObj.attr("schoolClassId",rtnValue.schoolClassId); //... } else{ if( rtnValue.message == "confirm" ){ $("#tiMetable_selectClass").find(".centerClassDialog").children("div").hide(); $("#tiMetable_selectClass").find(".centerClassDialog").children(".showMessages").show(); return; } } //隐藏[清空班级]option $("#tiMetable_selectClass").find(".selectStyleClass>option").each(function(){ if( $(this).val() == "remove_class"){ $(this).hide(); } }); //关闭对话框 dialogobj.close(); },strObj){ alert("程序出现错误:" + strError); } }); }); -------------------------------------------------ajax 返回json对象------------------------------------------------ //加载转圈图 <img class="loading" src="/images/loading_icon.gif"/> //加载swf文件 <div id="waitForLoading" class="wait_for_loading" style="position:relative;top:50px;display:none;"> <img src="<c:url value='/images/studyreport/baobao.gif'/>" style="position:absolute;"/> <img src="<c:url value='/images/studyreport/cycle_1.png'/>" style="position:absolute;left: 170px;top: 70px;"/> <img src="<c:url value='/images/studyreport/cycle_2.png'/>" style="position:absolute;left: 185px;top: 40px;"/> <img src="<c:url value='/images/studyreport/cycle_3.png'/>" style="position:absolute;width:203px;height:88px;top: -40px;left: 200px;"/> <span style="position:absolute;left: 225px;top: -10px;">慧话宝宝正在努力加载中......</span> <span style="position:absolute;left: 270px;top: 10px;">请耐心等候</span> <object type="application/x-shockwave-flash" data="<c:url value='/images/studyreport/loading.swf'/>" style="position: absolute;left: 220px;top: 100px;height: 60px;"/> </div> //JS性能测试用 var _startMonitorTime = 0; var _endMonitorTime=0; //打印用时 function printMointor( msg ){ var secondTime = (_endMonitorTime-_startMonitorTime)/1000; console.info(msg + secondTime); } _startMonitorTime = new Date().getTime(); _endMonitorTime = new Date().getTime(); printMointor("加载HTML用时:"); 原文链接:https://www.f2er.com/ajax/164379.html

猜你在找的Ajax相关文章