please checkout below code.
Here first ajax call in red , it response with "login".
in second part of this function, goes in IF condition and fn_up_track_price_drop_hanlder(); called.
fn_up_track_price_drop_hanlder() open jquery ui dialog box with login formand again save_Flight_track() called.
now First red coloured ajax call respond with key for applied login credentials.
it goes in else part and then second ajax has been called.
In between the popup close automatically as second ajax has been called.
So i want ot close popup only after whole second ajax call completed.
CODE:-
function save_Flight_track(cid,qid){
$.ajax({
type: 'GET',
cache: false,
async: false,
url: "/cgi-bin/b2c-v3/fn_login.cgi?session="+pd_sid,
timeout: 30000,
error: function(){
return true;
},
success: function(response){
if(response == "Login" || response == ""){
//return false;
response1= response;
} else {
pd_sid = response;
response1 = response;
//return true;
}
// return false;
}
});
//end of first ajax call
//jquery ui dialog box close after this which sholud not be.
var sysrt = document.getElementById('sysrt_cnt').value;
var url = '/cgi-bin/b2c-v3/track_fare.cgi?' +'qid=' + qid + '&cid=' + cid +'&session='+pd_sid+'&sysrt_cnt=' + sysrt;
//second part
if(response1 == "Login" || response1 == ""){
cid_track = cid;
qid_track = qid;
//display_login_frame("");
fn_up_track_price_drop_hanlder();
}else{
$.ajax({
type: "GET",
//cache: (temp_trip_my == 1 ? false : true),
//headers: (temp_trip_my == 1 ? {'Cache-Control': 'no-cache'} : {}),
cache: false,
headers: {'Cache-Control': 'no-cache'},
url: '/cgi-bin/b2c-v3/track_fare.cgi?' + 'qid=' + qid + '&cid=' + cid + '&session=' + pd_sid + '&sysrt_cnt=' + sysrt,
success: function (response) {
if (response == 'error' || response == '') {
showErrorDiv(this, 'flightdetail' + cid, cid, qid);
//alert( 'Unfortunately, we are unable to track this particular fare due to some technical difficulties. We apologize any inconvenience.' );
return false;
} else {
var arrdata = response.split(":");
if (arrdata[1] == 'new') {
// var tem_view = "track_price_Only";
var tem_view = "";
for (loop = 0; loop < flightData.length; loop++) {
if (flightData[loop].cid == cid) {
flightData[loop].track = 1;
flightData[loop].track_id = arrdata[0];
if ((flightData[loop].seats_left == 0) || (flightData[loop].seats_left == '')) {
tem_view = 'track_price_Only11';
} else {
tem_view = 'track_price_Only';
};
}
}
var line = "<font size='1'>";
line += "<a target='_blank' title='Click here to manage your trips' href='/cgi-bin/b2c-v3/fnuser/action_handler.cgi?action_param=track_flights&action=track_flights' style='color: #016A94;font: bold 11px Arial,Helvetica,sans-serif;text-decoration: underline;' class='" + tem_view + "'>";
line += "<div ><span class='planeTrack'></span><span class='pd_image_style' align=center></span>We're tracking this Flight</div></a></font>";
// line += "<div > <span class='pd_image_style' align=center> </span>My Trips</div></a></font>";
document.getElementById('track' + cid).innerHTML = line;
document.getElementById('track' + cid).className = 'mytrip';
// document.getElementById('track_img_'+cid).style.display = 'block';
var div_id = 'track_msg_' + cid + arrdata[1];
document.getElementById(div_id).style.display = 'block';
setTimeout("close_Div('" + div_id + "')", 10000);
setTimeout("welcome_email('" + qid + "','" + cid + "','" + arrdata[0] + "','" + arrdata[1] + "')", 2000);
} else {
// showalreadytrackDiv(this,'flightdetail'+cid, cid, qid);
$("#mfn_pop").dialog('open');
$("#mfn_pop").dialog({
height: 'auto',
width: '540px !important',
modal: true,
resizable: false,
autoOpen: true,
closeOnEscape: true,
position: 'center',
dialogClass: 'mfn_pop',
open: function (event, ui) {
$(".ui-widget-overlay").css({
'top': '0',
'left': '0',
'position': 'absolute',
'background': '#000000 url(//img.flightnetwork.com/flick/ui-bg_flat_0_000000_1x1.png) 50% 50% repeat-x',
'opacity': '.60',
'filter': 'Alpha(Opacity=80)'
});
$(".ui-dialog .ui-dialog-content").css({
'background': 'none',
'border': 'none'
});
$(".ui-dialog .ui-dialog-content").css({
'background': 'url(//img.flightnetwork.com/pp/mfn_pop.png) no-repeat',
'border': 'none'
});
$(".mfn_pop").css({
'background': 'url(//img.flightnetwork.com/pp/mfn_pop.png) no-repeat !important',
'height': '114px',
'width': '540 !important',
'display': 'block',
'min-height': '114px',
'padding-left': '0px'
});
$(".ui-dialog-titlebar").css('display', 'none');
$(".ui-widget-content").css({
'border': 'none'
});
}
});
$("#mfn_pop_close").click(function () {
$("#mfn_pop").dialog('close');
});
return false;
}
}
},
error: function () {
showErrorDiv(this, 'flightdetail' + cid, cid, qid);
//alert( 'Unfortunately, we are unable to track this particular fare due to some technical difficulties. We apologize any inconvenience.' );
return false;
}
});
}
}