I do not understand why but sometimes when I use .post() function the data are posted more than one time how can I control and stop this think? Thanks in advance.
best regards That's my 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>
");
});
}
},'xml'
);
break;
The problem is generated when I click on modifica, I get more than one button and data are posted several times..
ciao h
Generally this kind of things happens when end users having habit to double click the buttons uses your app. This may cause post request twice if you are not disabling the button after first click
I hope if you add code to appropriately handle this thing and that will resolve your problem. You can do following things for solution:
Hope this will help
You probably call the .post() twice.