Convert script from jQuery to Vanilla JavaScript

Hello. I was wondering if anyone could help me to change this jQuery AJAX Script to vanilla javascript. I don't really feel like importint a whole library to use only AJAX for my forms so i would appreciate it a lot if someone could help.
$(document).ready(function() {
$('.myForm').submit(function (event) {
var data = $(this);
$.ajax({
type: data.attr('method'),
url: data.attr('action'),
data: data.serialize(),
success: function (data) {
$('.output').html(data);
$('.myForm input:NOT([type=submit])').val('');
}
});
event.preventDefault();
});
});
$(document).ready(function() {
$('.myForm').submit(function (event) {
var data = $(this);
$.ajax({
type: data.attr('method'),
url: data.attr('action'),
data: data.serialize(),
success: function (data) {
$('.output').html(data);
$('.myForm input:NOT([type=submit])').val('');
}
});
event.preventDefault();
});
});
2 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Tok124 (CSS Nerd)
Tok124 (CSS Nerd)OP•2y ago
Ooh yeah, good idea. i will try and see what i get. chatgpt doesnt always give the best solution ^^ Okay yeah. That actually worked perfectly ! 😄
Want results from more Discord servers?
Add your server