Category Archives: Javascript

Output Ajax JSON Header in PHP

Overview of JSON JSON is an acronym for JavaScript Object Notation. It is essentially a way of exchanging data between a source and destination using name/value pairs. Commonly used when transferring data from a database to a website using AJAX. Generating a JSON object using php is pretty simple (although it won’t be covered [...]

2D Sprite Animation Tutorial

What are sprite animations? A sprite animation is basically a large image which contains a whole bunch of smaller images. Think of it as a film strip where each frame is the next piece of animation in the sequence. The idea of sprites is that you only need to load one image and it will [...]

Validate Email Address Online

Use the form below to check email address is valid. Simply enter an email into the box below and hit ‘validate’ to validate the email address online. It simply makes sure the format of the email address is correct and does not verify that the email address actually exists or belongs to anyone. You can [...]

Validate IP Addresses – Javascript and PHP Example

Below is a similar post to my other post on validate email addresses example except in this post we will validate an IP address instead of an email address. I have also provided simple and straight forward code snippets for Javascript and PHP. It uses a regular expression to test if the string passed to [...]

Pass a PHP Array to Javascript as JSON using AJAX and json_encode

Overview You will mostly likely (or already have) reached a point where you have a PHP array and you need to be able to access that array from inside a Javascript function. You may wonder if it is possible to pass an array from PHP to Javascript. Fortunately I have created a tutorial on how [...]

Regex to Replace All Except Specified Characters – Javascript and PHP Example

We can use regular expressions to specify a list characters we want to either strip out of a string or replace them with other characters however this post is aimed more at how to do a reverse strip or replace (also knows as a negative replace) where we specify the characters we DO NOT want [...]

Aborting an Ajax Request in jQuery

When using ajax to request a page or data, there will be occasions where you will need to cancel the ajax call. Some reasons may be that the page you are calling enters an infinite loop and stops the call from returning. Maybe you need to cancel a previous request before making a new request [...]

Validate Email Addresses – Javascript and PHP Example

This is a simple and straight forward article, which is similar to my other article, Validate IP Addresses and this article provides quick Javascript and PHP code snippets that can be used validate an email address. It uses a regular expression to test if the string passed to is a valid email address and returns [...]