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(); }); });
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
KP-C
Kevin Powell - Community
A friendly place for developers to meet other devs, ask questions, get help, and just have a good time 🙂.