jQuery ajaxForm and jQuery UI tabs
i have used tabs and jquery form plugin for my project. i have used only one function for handling the ajax request and respone for all tabs. Tabs contents are loaded based on the url. for each tab has the content of its own form. After submitting the form ,response will come to this corresponding tab based on the active tab.
But this functionality not working for me. The response came to different tab. Remember am using one one Function for handling Ajax request and response. so pls help me. very urgent.
My code is below
function initMyForm(myurl,myformid,targetDiv)
{
var myurlX = myurl;
var myfidX = myformid;
var targetDivX = targetDiv;
myTabsx = new YAHOO.widget.TabView('myTabs');
var index = myTabsx.get('activeIndex'); // get the active tab
var myTabx = myTabsx.getTab(index);
var mye = myTabx.get('contentEl'); //content of the active tab.
var mytarget = null;
// if targertDiv is null respose will be placed in active Tab content else the targetDiv
if(targetDivX == null || targetDivX =="")
{
mytarget = mye;
}
else
{
mytarget = $j(targetDivX);
}
var optionsa = {
target: mytarget, // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
// other available options:
url: myurlX, // override for form's 'action' attribute
type: 'post' // 'get' or 'post', override for form's 'method' attribute
// dataType: 'html' // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
// $j(myformid).ajaxForm(optionsa);
function showRequest(formData, jqForm) {
var queryString = $j.param(formData);
return true;
};
// post-submit callback
function showResponse(responseText, statusText) {
alert('REceived response');
};
$j.validator.setDefaults({
submitHandler: function() {
$j(myfidX).ajaxSubmit(optionsa);
}
});
}