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'/>",
? type: "post",
? async:true,
? data:{schoolClassId:schoolClassId},
? success: function( response ){
? $(".studyTimeRank").empty();
? $(".studyTimeRank").append(response);
? },
? error: function(reqObj, strError, 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'/>",
? ? type: "post",
? ? data:{yearWeekString:yearWeekString},
? ? dataType: "json",
? ? contentType:"application/x-www-form-urlencoded; charset=UTF-8" , ? //防止中文亂碼
? ? 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);
? ? });
? ? },
? ? error: function(reqObj, strError, 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'/>",
? ? type: "post",
? ? data:{classScheduleId:classScheduleId, schoolClassId:schoolClassId,?
? ? yearWeekString:yearWeekString, dayOfWeekCourseIndexString:dayOfWeekCourseIndexString,forceUpdate:forceUpdate},
? ? dataType: "json",
? ? contentType:"application/x-www-form-urlencoded; charset=UTF-8" , ? //防止中文亂碼
? ? 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();
? ? },
? ? error: function(reqObj, strError, 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用時:");
總結
以上是生活随笔為你收集整理的ajax工作中使用模板的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Java加密与解密的艺术~数字签名~EC
- 下一篇: Spring Data JPA 从入门到
