function afterSuccess(url){
$('#UploadForm').resetForm(); // reset form
$('#SubmitButton').removeAttr('disabled'); //enable submit button
$('#output').append('input').addClass('myCssClass').val(url);
}
ajaxsubmit target form input field
-
05-03-2022 - |
Question
I'm trying to figure out if ajaxSubmit is only able to target #div's or also other objects.
I have a script which uploads an image with ajax, and afer uploading the url of the image will be shown in a #div called Output. However, I want this url visible in an input field, not in a div.
<script>
$(document).ready(function() {
$('#UploadForm').on('submit', function(e) {
e.preventDefault();
$('#SubmitButton').attr('disabled', ''); // disable upload button
//show uploading message
$("#output").html('<div style="padding:10px"><img src="images/ajax-loader.gif" alt="Please Wait"/> <span>Uploading...</span></div>');
$(this).ajaxSubmit({
target: '#output',
success: afterSuccess //call function after success
});
});
});
function afterSuccess() {
$('#UploadForm').resetForm(); // reset form
$('#SubmitButton').removeAttr('disabled'); //enable submit button
}
</script>
So is it possible to target the name of the input field?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow