CodeIgniter Framework really help us Php developers to develop Web Apps easier , faster , well structured
and easy to maintain. As well as JQuery, help us in our daily Javascript needs. (This really helped my ass on
cross browser scripts).
In this demonstration will be validating an email and password field in Ajax, using CodeIgniter’s validation class and JQuery’s ajax functions.
First , create a simple Controller.
File : test.php

Then a view,

File : testview.php


We’re using CodeIgniter’s url helper class to write html forms.

Now let’s add JQuery.

Lets load the jquery script. In the testview.php we would insert this

In my setup, i’ve created a js folder in the root dir of your app where commonly used javascripts are stored there.

We should prevent the form’s submit action to redirect use after posting. So, we would write (in testview.php)

How could we submit the fields?. We would…
We used Jquery $.post function to post the form fields. $.post(url, post_vars, callback)
url -> the action url
post_vars -> post variables in a key : value pair
callback -> callback function ,server response to the post.

Actually were posting it to the Test controllers validate function. When the validation runs , it will print a string it if it is successful or not. Getting the string outputted by the validate function we could write a callback function in $.post :

When it returns Success, this would print Validation Success in the info div’s inner html.

Otherwise the error string generated by the validation class of CI.

You could test the demo here.

Source Code

There’s another approach on this, using a Jquery Form plugin.

free streaming anime

May 24, 2008

first post in may…

May 10, 2008

Speak… I don’t get it. Should I ignore your fashion Or go buy the book. I don’t want it, I just want your eyes fixated on me.

Currently watching @ crunchyroll

Desha Otoko

Majin Tantei Nougami Neuro

I really love Ito Misaki Ito. Just cried when she said”I also loved you”. It’s been a while when i cried for a drama series.

Including the tag <portlet:defineObjects/> in JSP pages is enough to access portlets specific elements, RenderRequest and RenderResponse. But sometimes, IDE like Eclipse would not offer code completion/assistance by just including that tag.

Including this, instead of the tag:

<%@ page import=”javax.portlet.RenderRequest” %>
<%@ page import=”javax.portlet.RenderResponse” %>
<%@ page import=”javax.portlet.PortletConfig” %>

<%
RenderRequest renderRequest = (RenderRequest)request.getAttribute(”javax.portlet.request”);
RenderResponse renderResponse = (RenderResponse)request.getAttribute(”javax.portlet.response”);
PortletConfig portletConfig = (PortletConfig)request.getAttribute(”javax.portlet.config”);
%>

Including this , Eclipse would offer code completion for you presentation pages.(eg. JSP )

Never forget to include portlet.jar on the build path.