jquery - Prevent multiple upload Ajax PHP -
currently experiencing issues multiple uploads on ajax.
i've tried:
e.preventdefault(); e.stopimmediatepropagation();
in function keeps duplicating anyways. can spam submit button , multiple uploads happen. suggestions?
$(document).ready(function () { /* data insert starts here */ $(document).on('submit', '#savepost', function (e) { e.preventdefault(); e.stopimmediatepropagation(); /* image upload ajax */ $.ajax({ url: "create.php", type: "post", data: new formdata(this), contenttype: false, cache: false, processdata: false, beforesend: function () { $("#err").fadeout(); }, success: function (data) { if (data == 'invalid file') { // invalid file format. $("#err").html("invalid file !").fadein(); } else { $("#dis").fadeout(); $("#dis").fadein('slow', function () { $("#dis").html('<div class="alert alert-info">' + data + '</div>'); // view uploaded file. $("#preview").html(data).fadein(); $("#savepost")[0].reset(); $("body").fadeout('slow', function () { $("body").fadeout('slow'); window.location.href = "memberpage.php"; }); }); } }, error: function (e) { $("#err").html(e).fadein(); } }); /* image upload ajax ending */ return false; }); /* data insert ends here */
Comments
Post a Comment