Ajax and Ajax Frameworks

I have been a developer for nearly 20 years and a web developer for about 10 years. Over the years, I have considered creating a blog to share the things I have learned (and am learning) about web design and development, but I never seemed to have the time. When I began learning about web development using Ajax and Ajax Frameworks, I decided to take the time to create this blog.

My intention for this blog is to focus primarily on Ajax Frameworks, but since web development requires knowledge of many technologies, I will occasionally write about things such as CSS, Javascript, PHP, MySQL, Flash, etc.

Lately, I have been using JQuery as my primary Ajax tool. Although I have used other Ajax Frameworks in the past (Dojo Toolkit, Yahoo! User Interface Library, Scriptaculous/Prototype), JQuery has thus far been the easiest to learn. In my first few posts I will discuss some of the JQuery Plugins that I have created. Some of these include: a plugin for Google Maps (jquery.imGoogleMaps), Form validation and submission  (jquery.imValidateForm), Page Populater (jquery.imPagePopulate), and a plugin to create lists (jquery.imList).

While I am still learning about some of the other Ajax Frameworks, I hope that what I have learned will be helpful to others. Just remember, “When you can pull the pebbles from my hand…”

Archive for the ‘Pebblet’ Category

While working on a project, I wanted to test whether a variable was undefined in Javascript. Because Firebug displayed ‘undefined’ in the console, I assumed that I could treat it as a string.

?View Code JAVASCRIPT
if (variable == 'undefined') {
// do something
}

Now I knew that this wouldn’t work, but I tried it anyway. ‘undefined’ an object, not a string, so I could not treat it as a string.

After a minute of searching, I found the undefined solution:

?View Code JAVASCRIPT
if (typeof(variable) == 'undefined') {
// do something
}

Using the typeof operator, Javascript is able to determine whether a variable/object is ‘undefined’.

Share

I was trying to find the version of XULRunner on my Ubuntu box.

sudo apt-cache showpkg xulrunner | less

This command will give you version and other relevant information about a package installed on Ubuntu.

Share

The following is a query to retrieve column names from a MySQL table:

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ‘table name’;

Share

I found a cool JSON validator.

http://www.jsonlint.com/

Share

When creating posts using WordPress, I often switch between the Visual and HTML editors. I write a lot of code in my posts (using the pre tag and the CodeBox plugin).

Unfortunately, when I switch back to the Visual editor, WordPress changes my code. Although, the code is wrapped in a pre tag, the visual editor will still change or remove code. For instance, If I add ‘ < script > ‘ to my page, I had to resort to writing < script >, so the visual editor does not change it.

It recently occurred to me that if I create a post with a lot of code, rather than trying to trick the Visual editor, I remain in the HTML editor and never switch back into the Visual editor before I publish.

I hope this helps someone else writing code using WordPress.

Share

If you are using an Ajax Framework with CakePHP and receive the error message “Missing View”, then you need to add the following to your controller method:

function someMethod() {
     $this->autoRender = false;
}

Also, if you have debug turned on, you will receive a Parse error when JSON data is returned back. CakePHP set the debug level to 2 by default. You can turn it off in the app/config/core.php file by setting the debug level to 0. YOu probably don’t want to do this in the development environment. A better solution is to add the following to your controller method:

function someMethod() {
     $this->autoRender = false;
     if ( $this->RequestHandler->isAjax() ) {
          Configure::write ( 'debug', 0 );
     }
}

This let’s CakePHP know that it is an Ajax request. If you use this method, make sure that you add the RequestHandler Component to your controller.

class MyController extends AppController {
        var $components = array('RequestHandler');
}
Share

Received an error using CakePHP: Missing Database Table. I am not using a database with this particular controller. To remove the error:

class ColorpalettesController extends AppController {
	var $uses = array();
}
Share

I just ran into a problem when I was attempting to pass a PHP POST variable that contained a period. I’m not sure why I have never run into this situation in the past. PHP will automatically convert a period into an underscore. I submitted a form  with a field with the name ‘co.uk’. I then checked for the existence of the post variable in a PHP class (if  $_POST['co.uk']). It did not exist. I then checked (if $_POST['co_uk']) and was able to get the value. Interesting.

Share

I just finished a project using CodeIgniter. I ftp’d the files to the host provider’s servers. When I attempted to view the website, I received a ’500 Internal Server Error’. Viewing the error logs, I found: SoftException in Application.cpp:252: File “/home/arrowcol/public_html/index.php” is writeable by group. I looked at the permissions of the index.php file and found that it was set to 0666, so I changed it to 0755 and the site is now up and running.

Share

Before I begin to learn any new language, I generally purchase a book or two. A few months ago, I purchased the book, “Professional CodeIgniter”. This is a really good book in that I could copy/paste/tweak much of the code from the book for an application that I was working on. I learned the basics and then some (integrating Ajax, TinyMCE, etc). I highly recommend it.

Share