Skip to content

Instantly share code, notes, and snippets.

(async function () {
let interval = null;
let counter = 0;
const fetch = async function(url) {
try {
return await $.ajax(url, {dataType: "json"});
} catch (error) {
console.log('Error:', error);
}
@JonnyNineToes
JonnyNineToes / Jquery Ajax
Last active October 25, 2024 12:22
Quick template for Jquery Ajax calls
// submit is an action performed ON THE FORM ITSELF...
// probably best to give the form an ID attribute and refer to it by that
$('form').submit( function (event) {
// prevent the usual form submission behaviour; the "action" attribute of the form
event.preventDefault();
// validation goes below...
// now for the big event
$.ajax({
// the server script you want to send your data to