Posts

Showing posts from December, 2013

Detect an AJAX Request in PHP

I like using the same PHP script for both AJAX and non-AJAX content requests. Using one script just makes everything easier because it's only one file to update/edit and it's one more cache-able request. One way to try detect an AJAX request (as opposed to a regular page load) is by using the following PHP code: /* decide what the content should be up here .... */$content=get_content(); //generic function; /* AJAX check */if(!empty($_SERVER['HTTP_X_REQUESTED_WITH'])&&strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){/* special ajax here */die($content)

CSS Click Event : Using CSS for Click Events

CSS doesn’t provide any official way to handle a click event in CSS. But there are some very interesting tricks that we can use to “detect” a click using CSS only, without a single line of JavaScript, and this is what we are going to talk about today. How ot Works ? The HTML 1 2 <inputtype="checkbox"> <