Skip to content

Instantly share code, notes, and snippets.

@FuriosoJack
Created November 21, 2018 03:00
Show Gist options
  • Save FuriosoJack/3d7dabce29b5f4835dc354dc3db3691a to your computer and use it in GitHub Desktop.
Save FuriosoJack/3d7dabce29b5f4835dc354dc3db3691a to your computer and use it in GitHub Desktop.
Ejemplo AJAX API
//////////////////////////////////////////
////////////////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