Ning Ma blog

my technology tips

JAVASCRIPT

using underscore to verify if a variable is undefined or null

Example of if a variable is undefined

Example of if a variable is null function test() { var foo = null; console.log(_.isNull(foo)); // true, var foo = 3; console.log(_.isNull(foo)); // false, }

Install node.js by yum (EPEL Repository)

Install Node from the EPEL Repository An alternative installation method uses the EPEL (Extra Packages for Enterprise Linux) repository that is available for CentOS and related distributions. To gain access to the EPEL repo, you must modify the repo-list of your installation. Fortunately, we can reconfigure access to this repository by installing a package available […]

run nodejs as a background by forever

How to run nodejs from background. Here is an easy way

Howevery, the forever will do more things, such like export log files, js api…

How to stop nodejs server? list node process and kill it.

sample of handlebars.js with underscore.js

From above sample code, we can define very clear template (no need JavaScript in the template source).

example of backbone.js validate

Here is a good example of backbone validate

If the object is banckbone Model

or

The instanceof operator tests whether an object has in its prototype chain the prototype property of a constructor.

jQuery large pictures with a loading spinner

Basic Version In our basic version, we will have a single div containing a loading spinner and once our large image is loaded (in the background) we will remove the spinner and insert our image. There’s a few ways to approach the loading screen, two of which are: Use a background image on the holder […]

Good example to security ajax call

Step-1 : Generate Token System For All Web-Service: Generating Token :

Step-2 : Use it while sending ajax call:

Step-3 : NOW, Let’s secure ajax handler PHP file with,

js form validation with JQuery

Here is good tutorial for js form validation with JQuery http://jqueryvalidation.org/documentation/

jquery render with object javascript and ajax example

HTML

Javascript

Ajax return data(JSON)

Previous Posts