Jquery-ajax control data post -
i not understand why when use .post() function data posted more 1 time how can control , stop think? in advance.
best regards that's code:
case "mod" : $.post("./php/"+eti[indice]+".php", {azione: "carica", contratto:contratto}, function(xml) { if ($("status", xml).text()=="1") { scorridati(xml); $.post("./php/"+eti[indice]+".php", {azione: "vedi", contratto: contratto }, function(xml) { if ($("status", xml).text()=="1") { var lun=$("#"+eti[indice]+"_"+indice).length; if (lun == 0) { $("#scheda_sch").append("<div style='clear:both'><div style='float:right' id='mod_def'><div id='"+eti[indice]+"_"+indice+"' class='bt'>modifica</div></div></div>"); scorridati(xml); } } else { $("#scheda_ris").html("<p><img src='./img/validyes.png' alt='ok'> attenzione!<br>codice non trovato!</p>"); } },'xml'); } else { $(xml).find("errore").each(function() { $("#scheda_ris").append("<img src='./img/validno.png' alt='errore'> <span style='color:red'>"+$(this).text()+"<br></span>\n"); }); } },'xml' ); break;
the problem generated when click on modifica, more 1 button , data posted several times..
ciao h
generally kind of things happens when end users having habit double click buttons uses app. may cause post request twice if not disabling button after first click
i hope if add code appropriately handle thing , resolve problem. can following things solution:
- disable control causes post event on first occurrence
- you can bind click , double click both events same function , use global variable stores count of click, if count > 1 don't click it. in result of post can make count 0 again.
hope help
Comments
Post a Comment