0
我有一些與jQuery UI的選項卡。每個鏈接應該收到一個JSON響應,但我無法使其工作。 這是活動的:JQuery UI選項卡寬度JSON響應
<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="ui-tabs-1" aria-labelledby="ui-id-1" aria-selected="true">
<a href="/comments.json" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-1">comments</a>
</li>
的迴應是:
[{"created_at":"2013-07-12T22:51:46Z","id":8,"programa_id":88,"sent_at":"2013-07-12T22:51:46Z","texto":"testing","updated_at":"2013-07-12T22:51:46Z","user_id":null}]
我試過幾件事情,但最好的方法是:
$("#tab_messages").tabs({
heightStyle: "fill",
beforeLoad: function(event, ui) {
ui.ajaxSettings.dataType = "json";
ui.ajaxSettings.dataFilter = function(data) {
var jsonData = $.parseJSON(data);
alert(jsonData[0].texto);
return jsonData[1].texto;
};
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo.");
});
}});
});
面板不加載(jqXHR.error出現),但如果我返回jsonData [1] .texto,它的工作原理是。