代码主要写在jsp文件里。刷新界面后是我需要的效果,但是点击里面的选项时,数据就没有了,之后不管怎么点,一样没数据。请问怎么解决?
其实你可以说得更抽象一点的,比如象这样,
我有一个问题不能解决,你们谁能解决。
这个问题是跟编程有关的。
我初学者,不知道该怎么说,就说了结果。只想知道个大体思路
@lrz8169: 初学者?
我说的是语文,你学了几年了,
现在小学就开始教JSP了吗?这个我倒是不知道...
你要这样问,能答上来的只有天桥下摆摊的...
@爱编程的大叔: 我也不清楚该怎么说,我复制代码你看看?
@爱编程的大叔:
<!DOCTYPE html>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="food" tagdir="/WEB-INF/tags/food"%>
<head>
<title>${fdtype.name}</title>
</head>
<body id="">
<div class="carte indexProper" id="bodyDiv">
<!-- start 首页的主要内容 -->
<div class="menu" id="menuLt">
<ul>
<li><a href="javaScript:void(0);" name="but-search" onclick="searchShow(this);" >
<em id ="icosearch" class="menu_search">搜索</em>
</a>
</li>
<li id="li-1"><a tabIndex="99" id="cateogryIndx_${status.index + 1}" class='curr' href="javaScript:void(0);" onclick="autoLoadData('${ctxPath }/food/food.html?storeId=${fdtype.syoufk}&fdtypeId=${fdtype.id}&type=${type}&cateogryIndx=${status.index + 1}#li-${status.index + 1}',this);" >
<em class="curr_icon${status.index + 1}" objid="${status.index + 1}">快速FAQ</em>
</a>
</li>
</ul>
</div>
<div class="carteRight">
<!--开始 导航下拉列表-->
<div class="mask">
<form name="foodSearchForm" id="foodSearchForm" method="get" action="${ctxPath}/food/food.html">
<div class="search" id="divSearch">
<input name="decorator" id="decorator" type="hidden" value="mainPage">
<input class="search_input"name="keywords" id="keywords" type="text"
value="${fditemtextSearchCriteria.keywords}" autocomplete="off" placeholder="输入文本...">
<input class="search_input"name="type" id="type" type="hidden" value="${type}">
<input name="fileType" id="fileType" type="hidden" value="doc">
<button class="btn-search" type="button" onclick="return searchSubmit();">搜索</button>
</div>
</form>
</div>
<!--结束 导航下拉列表 -->
<!-- 右边顶部选择分类 -->
<div class="content" id="contentRt">
<!-- 内容列表 开始-->
<div class="conten_mid">
<ul id="load" class="fl">
<section>
<li>
<div class="cont_fl">
<div class="txt">
<h3>如果在终端机打印影票时未能成功打印怎么办?</h3>
<p class="cl999">【院线通】遇到此类情况,首先检查取票口是否打印的电子票未掉落下来,若没有您可以寻求负责终端机打票的工作人员帮您处理,如最终无法打印影票,可向工作人员解释凭114短信进场。</p>
</div>
</div>
</li>
</section>
<c:if test="${sc.pageNo eq sc.totalPageCount}">
<div style="height: 20;line-height: 6" align="center">暂无更多数据</div>
</c:if>
<div style="display: none;">
<c:set var="searchUrl"
value="${ctxPath }/food/food.html?storeId=${fdtype.syoufk}&fdtypeId=${fdtype.id}&type=${type}" />
<c:choose>
<c:when test="${type eq 'search'}">
<c:set var="searchUrl" value="${ctxPath}/searchFood.html" />
</c:when>
</c:choose>
<input type="hidden" id="path" value="${searchUrl }"> <input
type="hidden" id="pageNo" name="pageNo" value="1"> <input
type="hidden" id="totalPageCount" name="totalPageCount"
value="${sc.totalPageCount}">
</div>
</ul>
<c:if test="${sc.pageNo < sc.totalPageCount}">
<div class="pages-nav" style="display:none">
<a href="javascript:void(0)" class="btn-gray load-more"
onclick="loadMore(this)" data-ajax="false"><span
style="color:red;"><fmt:message
key="common.message.showNext.10" />
</span>
</a>
</div>
<div id="loading" style="display:none;height: 20;line-height: 6"
align="center">
<img src="${imagePath}/no_txt/loadingBig.gif">
</div>
<div id="loadHtml" style="display:none;"></div>
</c:if>
<div class="pages-nav" id="load_more_div" style="display:none">
<a id="load_more" class="btn-gray load-more" data-ajax="false"><fmt:message
key="salesOrder.loadNextInformation" />
</a>
</div>
</div>
<!-- 内容列表 结束-->
</div>
</div>
<!-- end 首页的主要内容 -->
</div>
<%--
<c:set var="probizJs_dwr_util" value="true" scope="request" />
<c:set var="ui_dialog" value="true" scope="request" />
<script type="text/javascript" src="${ctxPath}/dwr/interface/bindMobileDwr.js?rs=${appConfig.rs}"></script>
<script type="text/javascript" src="${ctxPath}/scripts/probiz/customer/customerBind.js?rs=${appConfig.rs}"></script>
--%>
<%---------------------------------start:获取手机邀请码 -------------------------%>
<div style="display:none">
<probiz:ui_dialog id="customerBindPanel" width="80%" height="80%" title="获取手机邀请码" url="${ctxPath}/bindMoblie/blank.html" closeAfterFun="customerBindPanelCallback()" />
</div>
<%---------------------------------end: 获取手机邀请码 -------------------------%>
<script>
$j(document).ready(function() {
initDoc();
if(${type eq 'search'}) {
document.getElementById("divSearch").style.display="block";
}
if (parseInt($j("#totalPageCount").val()) == 1) {
$j("#load_more_div").hide();
} else {
//$j("#load_more_div").show();
}
setHeight(true);
});
$j.fn.extend({
loading:function(){
return this.each(function(){
$j(this).html('<div id="loading" style="height: 20;line-height: 6;padding-left: 50%;" align="center"><img src="${imagePath}/no_txt/loadingBig.gif"></div>');
});
}
});
</script>
<script>
function initDoc() {
document.body.height = screen.height;
document.getElementById("bodyDiv").style.height = screen.height;
}
function showDtl() {
$j("#ulMask").removeClass("disnone");
}
function hideDtl() {
$j("#ulMask").addClass("disnone");
}
function menu_icon(){
var o = $j("em:[class*='curr_icon']").get(0);
var index = $j(o).attr("objid");
$j(o).removeClass("curr_icon"+index);
$j(o).addClass("menu_icon"+index);
}
function searchShow(obj) {
$j(".mask_a").hide();
$j("li a").removeClass("curr");
$j(obj).addClass("curr");
$j("#icosearch").addClass("curr_search");
$j("#icosearch").removeClass("");
menu_icon();
$j("#divSearch").show();
}
function addtocart(obj,itemCode, rowid) {
if($j(obj).hasClass("btn_yes")){
$j(obj).addClass("btn_no")
$j(obj).removeClass("btn_yes")
delProductItem(itemCode,
function() {
refreshMinicart();
});
} else {
$j(obj).addClass("btn_yes")
$j(obj).removeClass("btn_no")
addToCart(itemCode, null, 1);
}
}
//显示详细面板
function showDetailPanel(fditemId){
dlgfditemDetail_show({'fditemId':fditemId});
}
function close_callback(){
//window.location.reload();
};
function shoppingcart(){
var shoppingcartItemCount = $j("span[name='shoppingcartItemCount']").text();
if(parseInt(shoppingcartItemCount)<1) {
dlgshoppingcartDetail_show();
} else {
window.location = "${ctxPath}/cart/shoppingcart.html";
}
}
function searchSubmit(){
var key = $j.trim($j("input[name=keywords]").val());
if(key != "") {
$('foodSearchForm').submit();
}
}
</script>
<script type="text/javascript">
var isLoadDataWithScroll = true; // 否可以加载过数据,true表示为可,反则不执行。
$j(document).ready(function(){
__FMTExtend = {
no_more:"<i18n:msg key="common.message.noMore"/>"
};
$j.extend(__FMT, __FMTExtend);
// 给浏览器窗口绑定 scroll 事件
$j("#contentRt").bind("scroll",function(){
nScrollTop = $j(document).scrollTop();
scrollHeight = $j(document).height();
clientHeight = $j(this).height();
//火狐跟google下,解决黑幕不够长的问题。
if((parseInt($j('.ui-dialog-overlay').css('height'))<scrollHeight)){
$j('.ui-dialog-overlay').css('height',scrollHeight+'px');
}
// 判断窗口的滚动条是否接近页面底部,scrollTop()==0的时候 就是顶端了
//$(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离
//$(document).height() //是获取整个页面的高度
//$(window).height() //是获取当前 也就是你浏览器所能看到的页面的那部分的高度 这个大小在你缩放浏览器窗口大小时 会改变
//$j("#contentRt")[0].scrollHeight //滚动条需要滚动的高度
//$j("#contentRt")[0].scrollTop //表示滚动条(一个点),即当前的位置
//if( $j(document).scrollTop()>=$j(document).height()-$j(window).height() && isLoadDataWithScroll )
if( $j("#contentRt").height()+ $j("#contentRt")[0].scrollTop >= $j("#contentRt")[0].scrollHeight && isLoadDataWithScroll ) {
// Ajax 翻页
autoLoadDataScroll();
}
});
//start 人数选择滑动
/**
var nums = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
SliderChooser({
nums: nums,
containerContext: 'section',
innerContext: 'ol',
itemContext: 'li',
itemWidth: 106,
currentStyleClass: 'curr',
callback: scCallback
});
scCallback(0);
if("${isSelClientAccount}" == "N"){
//一般从微信进来才需要选择人数
hideSelClientAccount();
}else{
showSelClientAccount();
}
**/
//暂时不使用人数选择
//hideSelClientAccount();
//end 人数选择滑动
/*
DWREngine.setAsync(false);
if(!isCustomerBindCheck()){
//未绑定,跳转到绑定页面
//window.location = __ctxPath+"/bindMoblie.html";
dlgcustomerBindPanel_show();
return;
}*/
});
var pageNo = 1;
function loadMore(el){
//var num = parseInt($j("#pageNo").val())+1;
var total = parseInt($j("#totalPageCount").val());
if(pageNo < total){
var url = $j("#path").val();
var paraData = {"PrmPageNo":pageNo+1,"loadMore":"3","decorator":"blank","orderby":"23"};
$j('#loadHtml').loading().load(url,paraData,finish);
//$j('#pageNo').val(num);
pageNo ++;
if(pageNo == total){
$j(el).text(__FMTExtend.no_more);
}
}
}
function finish(response){
var res=response.split("<!--列表 -->");
$j('#load').append(res[0]).find("li:last").hide();
$j('#load').find("li:last").slideDown(300);
}
//加载翻页后的数据
function autoLoadDataScroll(){
var total = parseInt($j("#totalPageCount").val());
if(pageNo < total){
var key = $j.trim($j("input[name=keywords]").val());
var url;
var paraData;
if(key != "") {
url= __ctxPath+"/food/book.html?storeId=1&type=${type}&keywords="+key;
paraData= {"PrmPageNo":pageNo+1,"loadMore":"3","decorator":"blank", "is_search":"1"};
}else{
url = $j("#path").val();
paraData= {"PrmPageNo":pageNo+1,"loadMore":"3","decorator":"blank","orderby":"23"};
}
$j("#loadHtml").show();
$j("#loading").show();
$j('#loadHtml').loading().load(url,paraData,finish);
//$j('#pageNo').val(num);
pageNo ++;
//$j("#load_more_div").show();
isLoadDataWithScroll = true;
} else {
$j("#loading").hide();
$j("#load_more").unbind();
$j("#load_more").html(__FMT.no_more).show();
isLoadDataWithScroll = false;
}
// 隐藏正在加载模块
$j("#loadHtml").loading().hide();
}
//加载主要内容列表数据
function autoLoadData(path,obj){
var paraData= {"PrmPageNo":1,"loadMore":"1","decorator":"blank"};
$j('#load').loading().load(path,paraData,function(response){
var res=response.split("<!--列表 -->");
$j('#load').html(res[0]);
$j('#divShowMask').html(res[1]);
pageNo=1;
isLoadDataWithScroll = true;
$j("input[name=keywords]").val("");
$j(".menu li a").removeClass("curr");
$j(obj).addClass("curr");
});
//取消搜索选中
$j(".mask_a").show();
$j("li a").removeClass("curr");
$j("#icosearch").addClass("menu_search");
$j("#icosearch").removeClass("curr_search");
$j("#divSearch").hide();
//选中的产品目录
menu_icon();
var o = $j(obj).find("em:first");
var index = $j(o).attr("objid");
$j(o).removeClass("menu_icon"+index);
$j(o).addClass("curr_icon"+index);
}
//调用dwr把人数存进cookie
function selClientAccount(){
var clientAccount = $j(".center").find(".curr").text();
addClientAcount(clientAccount, hideSelClientAccount) ;
}
//清除就餐人数的cookie
function clearClientAccount(){
addClientAcount(0, hideSelClientAccount) ;
}
//跳过人数选择
function hideSelClientAccount(){
$j(".shoppingcart_index").hide();
$j(".shoppingcart_main").show();
$j("#bodyDiv").css("background","");
}
function showSelClientAccount(){
$j(".shoppingcart_index").show();
$j(".shoppingcart_main").hide();
$j("#bodyDiv").css("background","background:#FFFFFF");
}
function SliderChooser(config){ var container = _q(config.containerContext), inner = _q(config.innerContext, container), nums = config.nums, itemW = config.itemWidth, curr = 1, w = container.clientWidth, drag_start = {time: 0, left: 0, top: 0, x: 0, y: 0, lx: 0, ly: 0}, drag_end = {left: 0}, directionLocked = null, time = function(){ return (new Date).getTime(); }, getP = function(e){ var t = e.touches[0], c = e.currentTarget.parentNode, r = c.parentNode.getClientRects()[0]; return { x: t.pageX-r.left, y: t.pageY-r.top, px: t.pageX, py: t.pageY, cx: t.clientX, cy: t.clientY, sx: t.screenX, sy: t.screenY }; }, getLeft = function(dom){ return parseFloat( /\((\-?[\.\d]+)px/.exec( dom.style[_vendor + 'Transform'] )[1] ); }, setCurr = function(idx) { curr = idx; _forEach(_qAll(config.itemContext, inner), function(li, liIdx){ _removeClass(li, config.currentStyleClass); if (idx == liIdx){ _addClass(li, config.currentStyleClass); } }); }, doTransition = function(value, tweenMode) { var d = tweenMode? /*as idx*/-value*itemW : value, s = tweenMode ? 6.18 * 4 * .01 : 0; inner.style[_vendor + 'TransitionDuration'] = s + 's'; inner.style[_vendor + 'Transform'] = _trnOpen + d + 'px,0' + _trnClose; }, e_ts = function(e) /*touchstart*/ { if (!_touchSupport) e.preventDefault(); directionLocked = null; var p1 = getP(e), p2 = { x: drag_end.left*1, y: inner.getClientRects()[0].top }; drag_start = { time: time(), left: p2.x, top: p2.y, x: parseInt(p2.x - p1.x), y: parseInt(p2.y - p1.y), lx: e.touches[0].clientX, ly: e.touches[0].clientY, point: p1 }; e.currentTarget.addEventListener("touchmove", e_tm); e.currentTarget.addEventListener("touchend", e_te); e.currentTarget.addEventListener("touchcancel", e_te); }, e_tm = function(e) /*touchmove*/ { if (!_touchSupport) e.preventDefault(); var p = getP(e), c = e.currentTarget.parentNode, v = drag_start.x + p.x; /*横纵拖动互不干扰*/ var absDistX, absDistY, deltaX = e.touches[0].pageX - drag_start.point.px, deltaY = e.touches[0].pageY - drag_start.point.py; if (directionLocked === "y") { return } else { if (directionLocked === "x") { e.preventDefault() } else { absDistX = Math.abs(deltaX); absDistY = Math.abs(deltaY); if (absDistX < 4) { return } if (absDistY > absDistX * 0.58) { directionLocked = "y"; return } else { e.preventDefault(); directionLocked = "x"; } } } doTransition( v ); if (MData(c, 'touching') === undefined || MData(c, 'touching')*1 != 1) MData(c, 'touching', 1); }, e_te = function(e) /*touchend*/ { if (!_touchSupport) e.preventDefault(); e.currentTarget.removeEventListener("touchmove", e_tm); e.currentTarget.removeEventListener("touchend", e_te); e.currentTarget.removeEventListener("touchcancel", e_te); var c = e.currentTarget.parentNode; MData(c, 'touching', 0); try{ drag_end.left = getLeft(c); }catch(ex){} var idx = curr, p2 = { x: drag_end.left, y: c.getClientRects()[0].top }, tTime = time() - drag_start.time, tDis = p2.x - drag_start.left, shortDis = Math.abs(tDis)<5, longTime = tTime > 300; if (!longTime && !shortDis){ /*快速拖动*/ if (tDis < 0) /*left*/ idx++; else /*right*/ idx--; }else{ /*一般拖动*/ if ( Math.abs(tDis) > .5*itemW ){ var d1 = Math.abs(Math.round(tDis/itemW)); if( tDis < 0 ) idx += d1; else idx -= d1; } } if (idx<1) idx = 1; if (idx>=nums.length-2) idx = nums.length-2; doTransition(idx-1, true); drag_end.left = getLeft(c); setCurr(idx); if ('callback' in config && !!config.callback){ config.callback.call(null, curr-1); } }; nums.unshift(-1); nums.push(-1); _forEach(nums, function(n,idx,arr){ inner.insertAdjacentHTML('beforeEnd', '<'+config.itemContext+'>'+n+'</'+config.itemContext+'>'); var li = _q(config.itemContext+':last-of-type', inner); if (idx==0 || idx == arr.length-1){ _addClass(li, 'sider'); return; } li.addEventListener("touchstart", e_ts); li = null; }); inner.style.width = itemW * nums.length + 'px'; setCurr(1); };
function scCallback(currIdx){
_forEach(_qAll('section li'), function(li){
_removeClass(li, 'left');
_removeClass(li, 'right');
});
var l = _q('section li:nth-of-type('+(currIdx+1)+')'),
r = _q('section li:nth-of-type('+(currIdx+3)+')');
_addClass(l, 'left');
_addClass(r, 'right');
l = null;
r = null;
_selectedCount = parseInt(_q('section li:nth-of-type('+(currIdx+2)+')').innerHTML);
}
function showOrderStatus(){
//dlgmyOrder_show();
}
function customerBindPanelCallback(){
}
/**
* 根据小分类id查询产品列表
*/
function selectType(obj, val,name){
var value = $j(obj).text();
$j("#viewText").text(value);
$j(".mask_box ul li a").removeClass("curr");
$j(obj).addClass("curr");
$j('#load').load( __ctxPath + "/food/blank.html?storeId=${fdtype.syoufk}&fdtypeId="+val+"&type=${type}&loadMore=1&decorator=blank",function(response){
var res=response.split("<!--列表 -->");
$j('#load').html(res[0]);
pageNo=1;
});
hideDtl();
$j(".mask_a").attr("varStatus", 0);
}
function showDivMask(obj) {
var varStatus = $j(obj).attr("varStatus");
if(varStatus == "0") {
showDtl();
$j(obj).attr("varStatus", 1);
} else {
hideDtl();
$j(obj).attr("varStatus", 0);
}
}
</script>
</body>
@lrz8169: 代码好长……、 也没有着色、没段落, 看得我连今晚的食欲都没了。
不要问现象,出现问题了,要能够自己定位。你刷新有数据,而点击没有数据。你要看看,点击的时候,有没有请求发送出去。装个fiddler自己监控一下。估计是js错了。
好的