2012-02-21 155 views
0

我正在使用jQuery选项卡(来自此示例:http://jqueryui.com/demos/tabs/#manipulation),并且希望添加一个包含来自外部源的内容的新选项卡。在获取数据之前,此外部源需要POST参数。来自外部源的结果应该创建并填充新选项卡,以在新选项卡上显示这些结果。jQueryUI选项卡 - 使用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 
    } 
); 
} 

我没有工作。其他人有这个设置的工作副本?

回答

0

我可能会在页面上做一个onLoad提交,你试图在标签中找到源代码,然后可以使用$(".ui-tabs-panel").html(postresponse);并在tab-wrapper中显示它,或者更改它到一个GET(Querystrings)而不是POST,使用GET会让这样的事情变得更容易。

+0

如果您使用GET,您将如何防止直接访问该页面? – Ourx 2012-02-21 04:56:25

+0

POST在这个意义上并不使它更安全。 – 2012-02-21 06:36:16

相关问题