Used specs: HTML5, Javascript
My question is as follows, I am trying to make a put request to the api from Phillips HUE and I found the following method of adding $.put to Jquery:
$.put = function(url, data, callback, type){
if ( $.isFunction(data) ){
type = type || callback,
callback = data,
data = {}
}
return $.ajax({
url: url,
type: 'PUT',
success: callback,
data: data,
contentType: type
});
}
My javascript file will get multiple methods and I want to know where I have to add this code so it will work in all my methods. Can I make a method that runs before all others and adds $.put to my JQuery for all methods or do I have to put this block of code inside every method?
Thanks in advance for your answers!
Greetings, Chiel
Responding to OP's comment:
To include a custom jQuery plugin, simply:
Here's an actual code example:
<script src="jquery.min.js"></script>
<script src="put.js"></script>
<script src="yourcode.js"></script>