Loading JSON-encoded AJAX content into jQuery UI tabs

后端 未结 3 862
夕颜
夕颜 2021-02-15 12:15

We want all of our AJAX calls in our web app to receive JSON-encoded content. In most places this is already done (e.g. in modals) and works fine.

However, when using j

3条回答
  •  清歌不尽
    2021-02-15 13:05

    You can use the dataFilter option of the ajax call to convert your json response to the html you want to be inserted in to the panel of the tab.

    Something like this:

    $('#mytabs').tabs({
        ajaxOptions: {
            dataFilter: function(result){
                var data = $.parseJSON(result);
                return data.myhtml;
            }
        },
    }); 
    

    If you JSON response looked like this:

    {"myhtml":"

    hello<\/h1>"}

提交回复
热议问题