/*========================================================, | Modifica via ajax il numero dei passeggeri e veicoli `========================================================*/ function ajx_change_passvehic(el,redir,routeid){ var pass_num = jQuery('#t'+routeid+'_passnum').val(); var vehic_num = jQuery('#t'+routeid+'_vehicnum').val(); var tipo = 'pass'; if(jQuery(el).attr('id') == 't1_vehicnum' || jQuery(el).attr('id') == 't2_vehicnum'){ var tipo = 'vehic'; } if(jQuery(el).attr('id') == 't1_passnum'){ jQuery('#t2_passnum option[value='+pass_num+']').attr('selected',true); } if(jQuery(el).attr('id') == 't1_vehicnum'){ jQuery('#t2_vehicnum option[value='+vehic_num+']').attr('selected',true); } if(vehic_num > pass_num){ alert("Il numero dei veicoli non può eccedere il numero dei passeggeri per la stessa tratta."); vehic_num = pass_num; jQuery('#t'+routeid+'_vehicnum option[value='+vehic_num+']').attr('selected',true); } var params = "tipo="+tipo+"&pass_num="+pass_num+"&vehic_num="+vehic_num+"&routeid="+routeid+"&token="+duck; jQuery.ajax({ mode:"abort", //sequence, //Matteo, commentato port: "22", //per richeiste differenti cambio la porta type :'POST', url : base_url + 'booking/ajx_change_passvehic' , //+ 'altri params url' data: params , async:false, // dataType : 'text', beforeSend:function() { //se ho inviato una richiesta ajax ritorno falso //da non mettere sempre dipende se do la possibilità di effetuare altre richieste //ho anche l'abort dell'ajax sequence /*if(ajaxsent){ return false; } ajaxsent = true; setTimeout(function(){ ajaxsent = false; },5000);*/ //altre azioni }, success:function(response) { var msg = jQuery.parseJSON(response); switch(msg['result']){ case 'ok': if(redir){ window.top.location = current_url; } break; case 'alert': if(msg['message'].length > 0){ alert(msg['message']); } break; case 'redir': if(msg['message'].length > 0){ alert(msg['message']); } if(msg['url_redir'].length > 0){ window.top.location = msg['url_redir']; } break; default: if(msg['message'].length > 0){ alert(msg['message']); } if(msg['url_redir'].length > 0){ window.top.location = current_url; } break; } } ,error:function (xhr){ if(xhr.status != 200) { console.log('aaaaaaaaaaaa'); return; //Matteo window.top.location = current_url; //jQuery.jqbox.load('Network error.Try again.',options); return false; } } }); return false; }