Created
December 18, 2014 17:00
-
-
Save goshmx/ef9b6be56ee9a510c3a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Funcion de peticion via AJAX | |
Ejemplo de Uso. | |
peticionApi('post','http://my-url.com','variable1=valor1&variable2=valor2') | |
.done(function(dato){ | |
//Codigo de ejecucion en codigo 200 | |
}) | |
.fail(function(){ | |
//Codigo de ejecucion en error | |
}); | |
*/ | |
function peticionApi(metodo,url,parametros,debug) { | |
var opcionesAjax ={ | |
type: metodo, | |
url: url, | |
dataType: "json" | |
}; | |
if((typeof parametros != 'undefined') || (parametros != false)){ | |
opcionesAjax.data = parametros; | |
}; | |
if(debug != 'undefined'){ | |
console.log("Peticion AJAX: "+metodo); | |
console.log("Peticion url: "+url); | |
console.log("Peticion parametros: "+parametros); | |
} | |
return $.ajax(opcionesAjax); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment