Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通行证;href";通过Ajax在jQuery UI tabs()中作为数据_Ajax_Jquery Ui_Jquery_Jquery Ui Tabs - Fatal编程技术网

通行证;href";通过Ajax在jQuery UI tabs()中作为数据

通行证;href";通过Ajax在jQuery UI tabs()中作为数据,ajax,jquery-ui,jquery,jquery-ui-tabs,Ajax,Jquery Ui,Jquery,Jquery Ui Tabs,我在页面的“index.php”中有一些选项卡(jqueryui选项卡)。此页面不仅显示内容,还检索$\u GET变量以显示选项卡下方的其他内容 问题是如何告诉jQuery用户界面href(点击的属性)是键“href”的值,该键必须发送(获取)到当前index.php页面,在JS haswindow.location.pathname(我不能使用php生成的JavaScript) 代码是这样的,我没有办法让事情顺利进行 jQuery('#front-tab').tabs({ spinne

我在页面的“index.php”中有一些选项卡(jqueryui选项卡)。此页面不仅显示内容,还检索
$\u GET
变量以显示选项卡下方的其他内容

问题是如何告诉jQuery用户界面
href
(点击的属性)是键“href”的值,该键必须发送(获取)到当前index.php页面,在JS has
window.location.pathname
(我不能使用php生成的JavaScript)

代码是这样的,我没有办法让事情顺利进行

jQuery('#front-tab').tabs({
    spinner: "Loading...",
    select: '#tab-one',
    cache: true,
    fx: {  height: 'toggle', opacity: 'toggle' },
    url: window.location.pathname,
    ajaxOptions: {
        type: 'get',
        success: function(){alert('Sucess');},
        error: function(){alert('I HAZ FAIL');};
        },
        dataType: 'html'
    }
});
HTML:

<div id="front-tab">
    <ul>
        <li><a href="#tab-home"><span>Home</span></a></li>
        <li><a href="tab-1"><span>Tab Content 1</span></a></li>
        <li><a href="tab-2"><span>Tab Content 2</span></a></li>
        <li><a href="tab-3"><span>Tab Content 3</span></a></li>
        <li><a href="tab-4"><span>Tab Content 4</span></a></li>
    </ul>
    <div id="tab-home">
        content...
    </div>
</div>

所容纳之物

是的,这让我每次尝试加载其他选项卡时都充满了“I HAZ FAIL”。第一个选项卡是内联HTML,但其余选项卡是Ajax<代码>url:window.location.pathname似乎不起作用或指向正确的方向。好吧,我不知道这是否符合我的要求。

好吧,在注意到jQuery UI选项卡的不灵活之后,我不得不自己复制操作。更好的是,与两个插件相比,只需要几行代码

function initTabs(elementHref) {
    jQuery('#front-tab').tabs({
        spinner: "Loading...",
        select: '#tab-one',
        cache: true,
        fx: {  height: 'toggle', opacity: 'toggle' },
        url: elementHref,
        ajaxOptions: {
            type: 'get',
            success: function(){alert('Sucess');},
            error: function(){alert('I HAZ FAIL');};
            },
            dataType: 'html'
        }
    });
}

jQuery('yourLink').on('click', function() {
    initTabs(jQuery(this).attr('href'));
});
front_tab.click(function(e) {
    // Content parent
    tab_content = $('#tab-content');

    // other variables
    var tab_visible = tab_content.children('div.visible'),
        span = $(this).children('span'),
        span_value = span.html(),
        value = $(this).attr('href'),
        // This gets our target div (if exists)
        target = tab_content.children(value);

    // There is no anchor
    e.preventDefault();

    // Don't do nothing if we are animating or "ajaxing"
    if (tab_content.children().is(':animated') || is_ajaxing) { return; };

    // Put the "selected" style to the clicked tab
    if (!$(this).hasClass('selected')) {
        front_tab.removeClass('selected');
        $(this).addClass('selected');
    }

    // If is target div, call it
    if (target.length > 0) {
        is_ajaxing = true;
        span.html('Loading...');
        tab_content.children().removeAttr('class');
        tab_visible.slideUp('slow', 'swing', function(){
            // Some timeout to slow down the animation
            setTimeout(function() {
                target.attr('class', 'visible').slideDown('slow');
                if (value = '#tpopular') { update_postbox(); }
                is_ajaxing = false;
                span.html(span_value)
            }, 400);
        });
    // So, the target div doesn't exists. We have to call it.
    } else {
        is_ajaxing = true;
        span.html('Cargando...');
        $.get(
        window.location.pathname,
        { href : value },
        function(data) {
                tab_visible.slideUp('slow', 'swing', function(){
                    setTimeout(function() {
                        tab_content.children().removeAttr('class');
                        tab_content
                            .append(unescape(data))
                            .children(value)
                            .css('display', 'none')
                            .attr('class', 'visible')
                            .slideDown('slow');
                        if (value = '#tpopular') { update_postbox(); }
                        is_ajaxing = false;
                        span.html(span_value)
                    }, 800);
                });
            },
        'html');
    }
});
下一个问题是发出一个漂亮的错误警告,但这就是解决方案。

提醒我“I HAZ失败”,但我不知道为什么。至少我可以说,你得到的美元不会传到页面上。-无论变量是否为空,我都在打印。