';
blockUIparams.message += '
(This operation may take up to 2 minutes...)
';
$.blockUI(blockUIparams);
// Post By Ajax to server
var retryCount = 0; // Number of retrys in case of timeout
var ajaxParams =
{
type : 'POST',
url : 'application_save.php',
dataType : 'json',
timeout: 180000, // It may take long time to save when large files are uploaded
cache: false,
data: data,
success : function(data){
if(data === null)
{
// This happens if there is connection error
if(retryCount)
{
retryCount--;
$.ajax(ajaxParams);
return;
}
data = { error: 1, msg: "Connection error.\\nPlease check your internet connection and try again.", stayonpage: true };
}
if(data.app_id && data.app_id > 0)
sw.smartWizard.setId(data.app_id);
if(!data.error && data.app_id > 0)
{
$('.save_draft').text('Save Changes');
// prevent warning of leaving the page
initData = JSON.stringify(sw.smartWizard.CollectDataFromSteps());
}
if ($.fn.jslog !== undefined)
$.fn.jslog(data.msg);
if (data.error || data.dialog || !data.app_id || data.app_id <= 0)
{
if(data.duplicateContester)
{
$.unblockUI();
$("#DuplicateContesterContent").html(data.duplicateContester);
$("#DuplicateContesterDialog").dialog('open');
return;
}
if(data.dialog)
{
$.unblockUI();
modalAlert(data.msg, {
modalStyles: {"padding":"30px","borderRadius":"5px","fontSize":"18px","border":"1px solid #FFFFFF","color":"#FFFFFF","backgroundColor":"#000000"} });
return;
}
blockUIparams.message = '
' + "Save failed!
"+ ''+data.msg.replace(/\n/g,"
")+'';
$.blockUI(blockUIparams);
setTimeout(function()
{
if (data.stayonpage)
$.unblockUI();
else
{
initData = DataB4Save; // prevent warning of leaving the page
window.location = "\/007roadtoamillion";
}
}, 4000);
}
else
{
// Success - send another ajax request, which will remove temp folder
$.post('application_save.php', { action: 'save_success', ADVID: '10iq39d7j1dk7jk5q16m6ljsjb', submission_id: 'submission_62994d22e75140.47478992', lang: 'en_GB' });
if (data.redirect) {
setTimeout(function()
{
// Decode html entities
window.location = $('
').html(data.redirect).text();
}, 100);
return;
}
if(overwrite_mode == 'update')
{
blockUIparams.message = 'Saved Successfully';
blockUIparams.timeout = 1000;
$.blockUI(blockUIparams);
}
else
{
$.unblockUI();
$('.wiz-nav-bar').remove();
$('#wizard-body').html('
');
if (typeof calcDynHeight!=="undefined"){
calcDynHeight();
}
}
}
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if ($.fn.jslog !== undefined)
$.fn.jslog(textStatus+' '+errorThrown);
if(textStatus == 'timeout')
{
// In case we got timeout, retry.
if(retryCount)
{
retryCount--;
$.ajax(ajaxParams);
return;
}
blockUIparams.message = '
' + "Connection timeout.\\nPlease check your internet connection and try again."+'';
}
else
blockUIparams.message = '
'+
"Connection error.\\nPlease check your internet connection and try again."+
''+(textStatus?textStatus+'
':'')+(errorThrown?errorThrown:'')+'';
$.blockUI(blockUIparams);
setTimeout('$.unblockUI();', 4000);
}
};
$.ajax(ajaxParams);
}