Created
May 12, 2020 08:39
-
-
Save zdimaz/675982241a41181710b1ddbfe41235c4 to your computer and use it in GitHub Desktop.
jq ajax form simple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ============================================== | |
Name function | |
============================================== */ | |
if($("form").length){ | |
$('form').submit(function(e) { | |
e.preventDefault(); | |
$.ajax({ | |
type: $(this).attr('method'), | |
url: $(this).attr('action'), | |
data: new FormData(this), | |
contentType: false, | |
cache: false, | |
processData: false, | |
success: function(result) { | |
alert(result); | |
}, | |
error: function(response) { | |
alert("Ошибка. Данные не отправленны." + response); | |
} | |
}); | |
}); | |
}; | |
/* ============================================== | |
End of Name function | |
============================================== */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment