+ -
当前位置:首页 → 问答吧 → 弹出层加载页面求助(我用JQuery impromptu 2.5)

弹出层加载页面求助(我用JQuery impromptu 2.5)

时间:2009-04-08

来源:互联网

我想使用弹出层加载一个页面,页面在加载时出现"页面正在加载中......",加载完后在弹出层里显示载内容。
我的弹出层使用JQuery impromptu 中的$.prompt()函数弹出的。
有哪位大侠可以指点一下,应该怎么做,我现在的做法就是先把弹同层关了再打开,但这样的效果很差,代码如下。
或者有别的好插件,好方法,介绍一下,谢谢!

注:我是在VS2008 MVC 中使用此方法,加载一个partialview 页面

function showPartial(url) {
var divid="_htmlcontent";
    var contentdiv = document.createElement("div");
    $(contentdiv).id = divid;
    $(contentdiv).text ( "页面正在加载中,请稍候......");
    var temp = {
    state0: {
            html: $(contentdiv).html()
        }
    }
    $.prompt(temp);
    $.ajax({
        type: "get",
        url: url,
        cache: false,
        error: function() {
            $.prompt.close();
            $.prompt('加载页面' + url + '时出错!');
        },
        success: function(msg) {
            $.prompt.close();
            $(contentdiv).text(msg);
            $.prompt($(contentdiv).html());
        }
    }
    );
    
}

作者: 逃话费   发布时间: 2009-04-08

挂了半天,没有人帮我解答,经过我自己的摸索,找到了一个解决问题的方法,但还是有些问题,还是把我摸索的成功贴出来,请老手指教。
就是加载页面如:http://www.163.com 加载不出来。
而且加载一个页面后,就可能加载每二次,加载每二次会出错!
function renderView(url, options) {
    var divid="_partialcontent_"+newGuid();
    var contentdiv = {innerHTML:"<div id=\""+divid+"\">页面正在加载中,请稍候......</div>"};
    var loaderid = "_content_" + newGuid();
    var loaderdiv ={innerHTML:"<div id=\""+loaderid+"\"></div>"};
    var temp = {
        state0: {
            html: contentdiv.innerHTML
        },
        state1:
        {
            html: loaderdiv.innerHTML
        }
    }
    try {
        if (options == null) {
            $.prompt(temp);
        }
        else {
            $.prompt(temp, options);
        }
    }
    catch (E) {
        alert( E.message);
    }
    $.ajax({
        type: "get",
        url: url,
        cache: false,
        error: function() {
            $.prompt.close();
            $.prompt('加载页面' + url + '时出错!', options);
        },
        success: function(msg) {
            var content = document.getElementById(loaderid);
            if (content != null) {
                $(content).load(url);
            }
            $.prompt.goToState("state1");
        }
    }
    );
}

作者: 逃话费   发布时间: 2009-04-08