Created
November 21, 2018 03:00
-
-
Save FuriosoJack/3d7dabce29b5f4835dc354dc3db3691a to your computer and use it in GitHub Desktop.
Ejemplo AJAX API
This file contains 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
////////////////////////////////////////// | |
////////////////Peticion get | |
$.ajax({ | |
url: "hptt://url", | |
dataType: "json", | |
data: "byPostID={{$post['data']['id']}}", //"_token=" + $("meta[name='csrf-token']").attr("content") + | |
method: "GET", | |
success: function (result) { | |
//Peticion exitosa se ejecuta alguna accion | |
}, | |
error: function (result) { | |
//Peticion fallida se muestra log en consola | |
console.log("Error PETICION GET") | |
} | |
}); | |
//////////////////////////// | |
////////////////////Peticion POST | |
$.ajax({ | |
url: "https", | |
dataType: "json", | |
data: {'hola': 'mundo'}, | |
method: "POST", | |
success: function (result) { | |
//Creacion existosa | |
}, | |
error: function (result) { | |
//Fallo petiicion | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment