Ho un problema nell'usare un input text dentro ad una finestra di dialog di Jquery ui. In pratica la seconda volta che inserisco un valore la mia variabile non si aggiorna almeno di non fare un refresh, nonostante la finestra venga chiusa e riaperta al nuovo click.
Qualcuno sa spiegarmi il perché e come ovviare al problema?
Grazie mille
codice:
function Compra(nome, valore, tipologia){
var merce = (nome);
var valore = (valore);
var tipologia = (tipologia);
if(valore == 1){
var denaro = 'moneta';
} else {
var denaro = 'monete';
};
$('<div>Vuoi acquistare '+merce+' per '+valore+' '+denaro+'?<br><br>Quantità: <input type="text" id="quantità" value="1"></div>').dialog({
buttons: {
"Campra": function(){
var quantità = document.getElementById('quantità').value;
var datiForm = new FormData();
datiForm.append('id_eroe',id_eroe);
datiForm.append('merce',merce);
datiForm.append('valore',valore);
datiForm.append('quantità',quantità);
datiForm.append('tipologia',tipologia);
$.ajax({
type: "POST",
url: "db/acquista.php",
data: datiForm,
cache: false,
processData: false,
contentType: false,
tryCount : 0,
retryLimit : 5,
success: function(data){
$("#refresh_store").load(location.href+" #refresh_store");
$("#refresh_zaino").load(location.href+" #refresh_zaino");
alert(data);
},
error: function(xhr, textStatus, errorThrown ) {
if (textStatus == 'timeout') {
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
$.ajax(this);
return;
}
return;
}
if (xhr.status == 500) {
///
} else {
alert('Errore! Impossibile completare l’azione.');
}
}
});
$(this).dialog("close");
},
"Lascia": function(){$(this).dialog("close");},
"Contratta": function(){$(this).dialog("close");}
}
});
};