1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<script>
$("#document").ready(function(){
//Initialisation
var mi = 10000;
var tps = 36;
var mens = 10000 / 36;
//Initialise les inputs
$("#chp1").val(mi);
$("#chp2").val(tps);
$("#chp3").val(Math.round(mens));
//Au FocusOut je lance la fonction "Ajax" via methode POST
//J'utilise json pour traiter mes données.
$("#chp1").blur(function(){
$.post('ajax_test.php', {
mi: $("#chp1").val(),
tps: $("#chp2").val(),
mens: $("#chp3").val()
}, function(data){
//J'ai maintenant un objet json
console.log(data);
//Que je peux manipuler directement...
$("#chp3").val(Math.round(data.mens));
}, "json");
});
});
</script> |