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
| $('#goarticle').on('click', function() {
var titre = $('#titre').val();
var auteur = $('#auteur').val();
var article= $('#article').val();
var imagearticle = $('#sortpicture').val();
if(imagearticle != ""){
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){
var imagearticles = php_script_response;
}
});
} else {
var imagearticles = "0";
}
$.ajax({
url : "creation.php",
type: "POST",
data: {auteur: auteur, imagearticle : imagearticles, titre : titre, article : article},
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