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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| $('#goarticle').on('click', function() {
var titre = $('#titre').val();
var auteur = $('#auteur').val();
var article= $('#article').val();
var imagearticle = $('#sortpicture').val();
var cat = $('#cat').val();
function startLoading()
{
var nValue = 0;
// création d'un timeout
var oTimer = setInterval (function (){
$("#progress").progressbar("value", nValue); // mets à jour la valeur de la barre de progression
nValue++;
if (nValue > 100) clearInterval(oTimer);
}, 200); // en ms
}
var file_data = $('#sortpicture').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url: 'upload.php', // point to server-side PHP script
dataType: 'text', // what to expect back from the PHP script, if anything
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function(php_script_response){
startLoading();
var imagearticles = php_script_response;
$('#goarticle').fadeOut();
$.ajax({
url : "creation.php",
type: "POST",
data: {auteur: auteur, imagearticle : imagearticles, titre : titre, article : article, cat : cat},
success: function(data) {
if(data == 'ok') {
$("#loading-div").fadeIn();
setTimeout(function() {
$('#loading-div').hide('blind', {}, 500)
}, 5000);
$("#btokcom").css({
"display" : "none"
});
alert("inscription réussie, vous allez recevoir un mail de confirmation, vérifiez vos spams, merci de votre fidélité");
} else {
alert(data);
}
}
});
}
}); |
Partager