ajaxOptions with TABS
ajaxOptions with TABS
With jQuery tabs I am attempting to use ajaxOptions to post data to the page before I load it.
So I have a form on the page before my tabs with some input fields. ie,
- <form id="myform" method="post">
- <!-- inputs etc -->
- </form>
Then my tabs
- <div id="tabs">
- <ul>
- <li><a href="#tabs-1">Preloaded</a></li>
- <li><a href="ajax/content1.html">Tab 1</a></li>
- </ul>
-
- <div id="tabs-1">
- <p>Initital content</p>
- </div>
- </div>
Now I should be able to serialize my form so when click a tab it should be a post request ie,
- $( "#tabs" ).tabs({
- ajaxOptions: {
- type: 'post',
- data: $("#myform").serialize(),
- error: function( xhr, status, index, anchor ) {
- $( anchor.hash ).html(
- "Couldn't load this tab. We'll try to fix this as soon as possible. " +
- "If this wouldn't be a demo." );
- }
- }
- });
It does perform the post request but the form data is always empty.
Any ideas why?