【问题标题】:jQueryUI Tabs - New tabs using POSTjQueryUI 选项卡 - 使用 POST 的新选项卡
【发布时间】:2012-02-21 03:50:10
【问题描述】:

我正在使用 jQuery 选项卡(来自此示例:http://jqueryui.com/demos/tabs/#manipulation)并希望添加一个包含来自外部源的内容的新选项卡。此外部源需要 POST 参数才能检索数据。从外部源返回的结果应创建并填充一个新选项卡,在新选项卡上显示这些结果。

$( "#tabs" ).tabs({
    ajaxOptions: {
        error: function( xhr, status, index, anchor ) {
            $( anchor.hash ).html("Unable to load content for this form. Please contact your web administrator");}
    }
});

...

function addTab() {
  $.post(
    "/test.php", // External source URL
    { id: "11" }, // Sets POST data
    function (data) {
        $('#tabs').tabs("add", data, $tab_title); // should create a new tab with the results from the external source
    }
  );
}

我没有工作。其他人有此设置的工作副本吗?

【问题讨论】:

    标签: jquery ajax post tabs jquery-ui-tabs


    【解决方案1】:

    我可能会在您尝试在选项卡中获取的页面上进行 onLoad 提交,然后是该帖子的结果,您可以使用 $(".ui-tabs-panel").html(postresponse); 并将其显示在选项卡包装器中,或者更改将它发送到 GET(查询字符串)而不是 POST,使用 GET 会使这样的事情变得容易 10 倍。

    【讨论】:

    • 如果您使用 GET,您将如何防止直接访问该页面?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-27
    相关资源
    最近更新 更多