Category

javascript

j

Implementing a class in JavaScript

let’s implement a class called FeedDog in JavaScript, that has an object inside which changes when a function is called!
var FeedDog=function(treat){var obj={treatSize:treat};
obj.increaseTreat=function(){
obj.treatSize++;
};
return obj;
}

Ajax call request in jquery

Making an ajax call using jquery is pretty simple, let’s create an ajax request that updates a specified contents every 20 seconds!
$.ajax({
url : 'YOUR URL WOULD GO HERE',
type : 'GET',
data : {
'parameter' : 10
},
dataType:'json',
success : function(data) {
console.log('Data: '+data);
},
error : function(request,error)
{
console.log("Request: "+JSON.stringify(request));
}
});

JavaScript Time events

Time is one important aspects in interaction design, animations, sliders, tabs, event loaders, etc. are depended on timer for proper functioning. JavaScript provides two amazing timing event api’s the first one is : SetTimeout(); //following is the code for calling this little sweet function window.setTimeout(function, milliseconds); //it takes a function and millisecond as the second...

Going Object with JavaScript

We have all been there, those random written variables and function that are good enough to do one simple task, but breaks often when used for more than one tasks, reason? well, it’s because the code is meant for just one purpose, this is where object oriented programing comes in to rescue.

Latest from Sarabpreet