CakePHP sessions

Posted: February 9th, 2010 | Author: admin | Filed under: Javascript, PHP | No Comments »

If you are developing an CakePHP application where ajax is mostly used. It is advisable that you set the following session configurations inside your core.php.

Configure::write('Session.timeout', '86400'); // expires in 30 days

Configure::write('Security.level', 'medium');

If your application calls more than one ajax request at the same time, it is recommended that you set your ajax requests to synchronous to prevent session regeneration id errors.


How to check if a plugin has been loaded in jQuery?

Posted: February 9th, 2010 | Author: admin | Filed under: Javascript | Tags: | No Comments »

This tutorial illustrates how to check if a plugin exists or if plugin has been already loaded usingĀ  jQuery. This is particularly useful if you are writing your jQuery code that depends on that plugin.

if(jQuery().plugin_name) {
// plugin exists
} else {
// plugin not loaded
}

Get value of radio button using jQuery

Posted: June 8th, 2009 | Author: admin | Filed under: Javascript | Tags: , | 2 Comments »

Here’s a tutorial on how to get the value of a checked or selected radio button out of a group of radio buttons:

...
<input type="radio" name="sample" value="1" />
<input type="radio" name="sample" value="2" checked="checked" />
<input type="radio" name="sample" value="3" />
...

//javascript code

<script type="text/javascript">
<!--
    // displays the selected radio button in an alert box
    alert($('input[name=sample]:checked').val())
-->
</script>

Ajax preloading/loading animation using jQuery BlockUI

Posted: May 20th, 2009 | Author: admin | Filed under: Javascript | Tags: , , | No Comments »

This tutorial shows you how to block/disable your web page whenever an application is processing an ajax request. First, you would have to download the latest jQuery library and the jQuery BlockUI plugin. Usage is very simple; Here’s a sample to block user activity for the page whenever an ajax request is called:

<script type="text/javascript" src="jquery-latest.js" language="javascript"></script>
<script type="text/javascript" src="jquery.blockui.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
<!--
	$(document).ready( function () {
		<!-- Page block animation during ajax requests -->
		$().ajaxStart($.blockUI).ajaxStop($.unblockUI);		

		$('#form_button').click( function () {
			$.ajax({
			<!-- Ajax actions here -->
				....
			});
		});
	});
-->
</script>

For more options on using jQuery BlockUI plugin go here


Cool Ajax Preload Images

Posted: May 20th, 2009 | Author: admin | Filed under: Javascript | Tags: , | No Comments »

If you’re looking for cool ajax preloading animated images, go to http://www.ajaxload.info. You get to customize your preload images and download them for free. Try it out!