`

jQuery加载(load、get、post)页面显示空白原因

    博客分类:
  • js
 
阅读更多

郁闷国庆几天了,终于查出为何load一个目标页面(html,jsp,php等)会显示空白,而直接打开又正常显示

尝试了N种办法,终于找出原因:

1、存在没有完全成对闭合的HTML标签(如DIV、UL、LI等)

2、加载目标页面可以正常使用JS代码,并被正常加载生效

 

经过这两天的搜索与验证;网上的人都说生成的目标页面不能包括js或css;或者说目标页面的内容过多显示不出来;

其实这是个错误的认识;

 

$("#content").load("receiveList.ftl")

 

 目标文件:receiveList.ftl

<style type="text/css">
    html, body {
        overflow-y: hidden;
    }

    .innera {
        overflow: auto;
    }

    .m1 td {
        border-bottom: 1px solid #ebebeb;
    }

    table.m1 {
        -width: auto;

    }
</style>
<div class="normal_blk overflow_h">
    <h2 class="title">
        <span class="table_normalbg">收件箱<em class="mail_list">(共${paging.totalCount} 封,其中 未读邮件${noReadCount} 封。)</em></span>
    </h2>

    <div class="text">
        <div class="cz_bar overflow_h">
            <div style="margin:7px 173px 0 0;">
          <span class="float_r" style="margin-top:5px;">
              <form>
                  <input type="hidden" id="pageCount" value="${pageCount}"/>
                  <input type="hidden" id="start" value="${pageCurrent}"/>
                  共[<em>${paging.totalCount}</em>]条纪录
                  第[<em>${pageCurrent}</em>]页&nbsp;
                  共[<em>${pageCount}</em>]页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <#if pageCurrent gt 1 >
                  <a href="javascript:page(1);">首页</a>

              </#if>
              <#if pageCurrent gt 1 && (pageCount>=pageCurrent)>
                  <a href="javascript:page(${pageCurrent-1});" class="blue">上一页</a>
              </#if>

              <#if  (pageCurrent+1)<=pageCount>
                  <a href="javascript:page(${pageCurrent+1});" class="blue">下一页</a>
              </#if>

              <#if pageCount!=pageCurrent>
                  <a href="javascript:page(${pageCount});" class="blue">尾页</a>
              </#if>
                  &nbsp;&nbsp;&nbsp;跳到
                  <input type="text" name="index" size=3 onkeyup="checkInput(event);" value='${pageCurrent}'>页
                  <a href="javascript:void(0);" onclick="page(document.forms[0].index.value)" class="blue"><b>GO!</b></a>
              </form>
</span>

          <span style="float:left">
           <div class="fl_l">
               <input type="button" value="删除" id="btn_delete" onclick="deleteEmail();"/><input type="button" value="彻底删除" id="btn_sure_delete" onclick="sureDeleteEmail();"/>
               <input type="button" value="转发" onclick="email_forward();"/>
               <select onchange="moveTo(this.value)">
                   <option>移动到...</option>
                   <option value="emailDraft">草稿箱</option>
                   <option value="emailSend">发件箱</option>
               </select></div>
            </div>
            </span>
        </div>
        <div class="overflow_h">

             <@property name="comeGo"/>
         </div>
            <div style="margin-right:174px; -margin-right:171px;">
                <div class="overflow_h">
                    <div class="outer">
                        <table  >
                            <thead>
                            <tr>
                                <th style="width:30px;">
                                    <span class="r_line"><input type="checkbox" onclick="checkMainBox();" id="maincheckbox"/></span>
                                </th>
                                <th style="width:44px;"><span class="r_line"></span></th>
                                <th style="width:138px;"><span class="r_line">发件人</span></th>
                                <th style="width:629px;"><span class="r_line">主题</span></th>
                                <th style="width:138px;"><span class="r_line" style="background:none;">时间</span></th>
                            </tr>
                            </thead>
                        </table>
                        <div class="innera" id="innera">
                            <table id="Table1" class="m1">
                                <tbody>
                                <#if paging.data ??>
                                    <#list paging.data as c>

                                    <tr class="demo3 unload" id="tr${c.docId}" onmouseover="">
                                        <td style="width:30px;">
                                            <input type="checkbox" name="subcheckboxs" value="${c.docId}" />
                                        </td>
                                        <td style="width:44px;"><img src="<@$img.prototype file="mail_black.gif"/>"/>
                                            <img src="<@$img.prototype file="Attachment.gif"/>"/></td>
                                        <td style="width:138px;">
                                            <a href="javascript:void(0);" onclick="read(${c.docId});" title="${c.docSubject?default('')}">
                                                <#if (c.docSubject ??)&&(c.docSubject?length gt 15)>
         ${c.docSubject?substring(0,15)}
            <#else >
                                                ${c.docSubject?default('')}
                                                </#if>
                                            </a>
                                         <input type="hidden" id="docSubject${c.docId}" value="${c.docSubject?default('')}"  />
                                        </td>
                                        <td style="width:629px;">
                                            <a href="javascript:void(0);" onclick="read(${c.docId});">
                                                <#if (c.docName ??)&&(c.docName?length gt 35)>
        ${c.docName?substring(0,35)}
            <#else >
                                                ${c.docName?default('')}
                                                </#if>
                                            </a></td>
                                        <td style="width:138px;">${c.createdate?string('yyyy-MM-dd')} </td>
                                    </tr>

                                    </#list>
                                    <#else>
                                    <tr class="demo3 unload">
                                        <td colspan="5">暂时邮件</td>
                                    </tr>
                                </#if>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
 

<script language="javascript" type="text/javascript">
    function page(index)
    {
        if(index == "")
        {
            alert("请输入跳转的页面数!");
            return;
        }
    //    if(isNaN(document.forms[0].index.value))
    //    {
     //       alert("跳转页面必须为数值型");
    //        return;
     //   }
        if(index == 0)
        {
            index = 1;
        }
        if(index > ${pageCount})
            index = "" + ${pageCount};

        doLoad("${componentPath}/email-receive?start=" + index,"content");
    }

    function checkInput(event)
    {
        var currKey = 0
        var e = event || e;
        currKey = e.keyCode || e.which || e.charCode;
        if(currKey == 13)
        {
            page(document.forms[0].index.value);
            /// return;
        }
        else if((currKey >= 48 && currKey <= 57) || (currKey >= 96 && currKey <= 105) ||
            currKey == 8 || currKey == 37 || currKey == 39 || currKey == 127)
        {

        }

    }
     function doing(){
         alert("doing");
      $(".m1 tr:even").addClass("tdOdd");
        //$("th:first").css("background","");//首个
        $(".m1 tr").mouseover(
            function()
            {
                $(this).addClass("tdOver");
            }).mouseout(
            function()
            {
                $(this).removeClass("tdOver");
            }).click(function()
            {//荧光棒
                $(".tdClick").removeClass("tdClick");
                $(this).addClass("tdClick");
                   alert(this.id);
                      docomeGo(this.id);//处理loadcomeGo

            })//行锁定

     }
    alert(1);
     doing();
   window.onload=function(){

       alert(2);
}

</script>


 

上面的目标文件很长了,也包括着js了;一样在ie8,和ff浏览器正常显示;

0
1
分享到:
评论
1 楼 skykufo 2015-07-07  
坑爹啊,我也因为写多了一个div,在ie8浪费了一天 

相关推荐

    jquery-get-post-load 方法

    jquery-get-post-load 方法

    jquery最全面的ajax例子 ajax post get load 应有尽有

    $.get()和$.post()方法 、 $.getScript()和$.getJson() 、 $.ajax()方法 、 序列化元素 、 jQuery中的Ajax全局事件 这些都有详尽的例子,一看代码,你就能明白jquery里实现ajax是怎么回事了,简单明了。

    jquery 读取页面load get post ajax 四种方式代码写法

    jquery 读取页面load get post ajax 四种方式代码写法,学习jquery的朋友可以参考下。

    详谈jQuery Ajax(load,post,get,ajax)的用法

    今天看到群里面有网友们问到Jquery Ajax的(load,post,get,ajax)之间的区别,现在整理了一篇文章出来,希望可以帮到网友们,首先我们先来看一些简单的方法, 这些方法都是对jQuery.ajax()进行封装以方便我们使用的...

    jquery中get和post的简单实例

    用法1:(页面载入时读取远程页面内容到divMsg) $(“#divMsg”).load(http://localhost:8012/t.php, { “resultType”: “html” }); 返回类型resultType有如下几种: “xml”, “html”, “script”, “json”, ...

    防止jQuery ajax Load使用缓存的方法小结

    一、用法 jquery的load函数是请求另一个文件并加载到当前DOM里的调用,load方法的完整格式是:load( url, [data], [callback] )(注意没有参数是GET方式请求,有参数则是 POST方法)。 * url:是指要导入文件的地址。...

    jQuery中ajax的load()与post()方法实例详解

    在jQuery ajax的load()方法能够载入远程 HTML 文件代码并插入至 DOM 中,这个与post,get还是有一点的区别,但可以快速在页面加载时就加载一个页面的html保存到dom中并且可执行哦。 load()方法默认使用 GET 方式, 如果...

    详解jQuery中ajax.load()方法

    load()函数默认使用GET方式,如果提供了对象形式的数据,则自动转为POST方式。 因为默认使用的是Get请求方式,所以我们也可以在url加数据进行提交。 例如$("#box").load("loadTest.html?name=zhang&age=25"

    jQuery权威指南-源代码

    6.1.2 jQuery中的load()方法/162 6.1.3 jQuery中的全局函数getJSON()/164 6.1.4 jQuery中的全局函数getScript()/166 6.1.5 jQuery中异步加载XML文档/168 6.2 请求服务器数据/170 6.2.1 $.get()请求数据/170 ...

    jqueryAjax

    jquery的各种ajax请求,包括get,post,load,ajax等

    jquery插件使用方法大全

    要等到页面全部加载完毕才执行,注意是全部加载,包括dom,图片等其它资源。 而$(document).ready(function(){ alert&#40;"hello"&#41;; });(1) 当dom加载完就可以执行了。 代码1同时做到表现和逻辑分离。并且可以在...

    jQuery中Ajax的get、post等方法详解

    在项目中,如果需要传递一些参数给服务器中的页面,那么可以使用$.get()或者$.post()方法(或者是$.ajax()方法) $.get()方法使用GET方式来进行异步请求。结构为:$.get(url [, data] [, callback] [, type]) $.get()...

    jQuery Ajax之$.get()方法和$.post()方法

    注意:$.get()和$.post()方法是jQuery中的全局函数。前面讲到的load()方式是对jQuery对象进行操作的。 1、 $.get()方法  $.get()方法使用GET方式来进行异步请求。  它的语法结构为:  $.get( url [, data] [, ...

    jquery电子文档chm

    type (String) : (默认: "GET") 请求方式 ("POST" 或 "GET"), 默认为 "GET"。注意:其它 HTTP 请求方法,如 PUT 和 DELETE 也可以使用,但仅部分浏览器支持。 url (String) : (默认: 当前页地址) 发送请求的地址。...

    jQuery 1.4.1 中文参考

    10.1.6 jQuery.post(url, [data], [callback], [type]) 174 10.2 Ajax 事件 175 10.2.1 ajaxComplete(callback) 175 10.2.2 ajaxError(callback) 175 10.2.3 ajaxSend(callback) 176 10.2.4 ajaxStart(callback) 176...

    jquery-1.1.3 效率提高800%

    jQuery.get( url, [data], [callback] )参数: url (String): 装入页面的URL地址 Map(可选): (可选)发送到服务端的键/值对参数 callback (Function): (可选) 当远程页面装入完成时执行的函数 ...

    jQuery中ajax – get() 方法实例详解

    在jquery中使用get,post和ajax方法给服务器端传递数据,在上篇文章给大家分享了jquery中ajax-post()方法实例,下面通过本文继续学习jQuery中ajax – get() 方法,具体介绍请看下文。 jQuery Ajax 参考手册 实例 ...

    JQuery权威指南源代码

    jQuery代码检测页面元素 使用jQuery基本选择器 使用jQuery层次选择器 使用jQuery基本过滤选择器 使用jQuery内容过滤选择器 使用jQuery可见性过滤选择器 使用jQuery属性过滤选择器 使用jQuery子元素过滤选择器...

Global site tag (gtag.js) - Google Analytics