From jQuery UI tabs:
<script>
$(function() {
$( "#tabs" ).tabs({
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html("Couldn't load this tab.");
}
}
});
});
</script>
<div class="demo">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Preloaded</a></li>
<li><a href="ajax/content1.html">Tab 1</a></li>
<li><a href="ajax/content2.html">Tab 2</a></li>
</ul>
<div id="tabs-1">
<p>Proin elit arcu, rutrum commodo.</p>
</div>
How to send ajax request with post data in this case (maybe through ajaxOptions).
I do not know how to modify tabs urls to send post data, for example:
<li><a href="ajax/content1.html(country:1,city:35)">Tab 1</a></li>
<li><a href="ajax/content2.html(code:'aa')">Tab 1</a></li>
Thanks!
EDITED:
In jQuery it’s:
$.load("some_url",{country: countryValue});
So I have post header (country) and post value (countryValue).
How to do the same with each tab?
To make the AJAX method POST, you can add a
typeto theajaxOptionsobject. To collect data for the post, you could take advantage ofjQuery.data()and then hide the POST parameters in the anchor.And the JavaScript:
Try it: JSFiddle
If your parameters change for each link, you’ll have to come up with a way to know which parameters you’re looking for. You could get the index of the tab in the
select()event usingui.indexand use aswitchto get different parameters for each case. Admittedly this solution isn’t very pretty, but it could work.