Static variables in JavaScript

If you come from a class-based, statically typed object-oriented language (like Java, C++ or C#) I assume that you are trying to create a variable or method associated to a “type” but not to an instance. An example using a “classical” approach, with constructor functions maybe could help you to catch the concepts of basic OO JavaScript: … Read more

getElementById returns null?

It can be caused by: Invalid HTML syntax (some tag is not closed or similar error) Duplicate IDs – there are two HTML DOM elements with the same ID Maybe element you are trying to get by ID is created dynamically (loaded by ajax or created by script)? Please, post your code.

How to call a JavaScript function from PHP?

As far as PHP is concerned (or really, a web server in general), an HTML page is nothing more complicated than a big string. All the fancy work you can do with language like PHP – reading from databases and web services and all that – the ultimate end goal is the exact same basic … Read more

Base64 encoding and decoding in client-side Javascript

Some browsers such as Firefox, Chrome, Safari, Opera and IE10+ can handle Base64 natively. Take a look at this Stackoverflow question. It’s using btoa() and atob() functions. For server-side JavaScript (Node), you can use Buffers to decode. If you are going for a cross-browser solution, there are existing libraries like CryptoJS or code like: http://ntt.cc/2008/01/19/base64-encoder-decoder-with-javascript.html (Archive) With the latter, you need to thoroughly test … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)