Cool Ajax - Web Development Tutorial Blog

Category : Quick Tips

How to Detect AJAX Request using PHP

Detecting AJAX request is very useful, while your are working in AJAX based pagination. Last day worked in a project and I need to detect ajax or direct post request. Following script help me to detect AJAX request. Very simple but efficient script. if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ //If AJAX Request Then }else{ //something else } Was this information useful? [...]


Array flip and reverse in php

Flip and reverse sounds similar. Don’t mix-up them 🙂 array_flip function is useful when you only want to shift array index as array value and vice-verse. On the other hand if you want to change only array index in descending/reverse order then array_reverse function works great. Array flip convert key in to index and index in to key. $a = [...]


Simple way to define a custom error page using htaccess

A nice error page can make your website more user friendly. You know there are several kinds of error can occur in a web application or website and they have their own status codes. If you handle them smart way then it can create a good impression for your website. One of the most common and popular way for handing [...]


How to convert string in to slug using JavaScript

Today we are going to learn how to convert string to slug using JavaScript. We will write a custom JavaScript function called “convertToSlug” and it makes our string as a slug value. I’m sure enough, it will be a fun to create slug in JavaScript. Have a look at code snippet- /***************************************************** *@Description: Convert any string in to slug URL. [...]


How To Improve Web Application Performance

Web application performance is a great fact for application success. Mainly, website performance refers content loading speed. Now a days most of the time we use web application in mobile phone and visitors like to load those application that loads less than 3-4 seconds. So, that we should keep our content so light and make it super fast. Suppose, you [...]


Easy way to parse comma separated item in PHP

Welcome Quick tips#2. Last day, in Quick tips#1 we learned How to Get Remote IP Address in PHP. Today We are going to learn about PHP Parsing. Using PHP, we can easily extract the individual elements of a comma-separated list. PHP has a great function named explode() that makes a comma-separated string list into an array of individual list elements. [...]


How to Get Remote IP Address in PHP

From today I’m going to introduce a new section called “Quick Tips” in my website. Here, I’ll share php/css/js/jQuery/WP snippets. It will be a fun. Let’s get started- Quick Tips#1: Today we are going to learn “How to Get Remote IP Address in PHP”. PHP has built-in facility to detect remote browser or IP address and other properties. These values [...]