Wednesday, 14 December 2011

Ajax

AJAX = Asynchronous JavaScript and XML.

AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.

You can call function that contain AJAX on any event as:- onclick, onsubmit etc. of the form or button.

As:- <button type="button" onclick="functionname()">Change Content</button>

Syntex of AJAX in any function is : -

function anyname() {
      $.ajax({ 
            type: "POST",
            url: webURL + "path",   
            data: "variable="+value,  
            success: function(msg)     
            {
              if(msg!='')
                {--------}
            }
        });
}

//path is :-path of controller and its function you want to call for processing .
// variable :-parameters you want to sent .
// msg :- after return from controller 'msg' contain values that controller return.

Friday, 9 December 2011

Java Script for not allow 'Space'

function nameoffun()
{
    var name = document.getElementById('inputboxid').value;
    var pattern = /^[a-zA-Z0-9]+$/;  //it  allow only alphanumeric characters, not allow space  b/w them..  
     if(pattern.test(name))
           return true;
    else
          return false;
  }

Wednesday, 7 December 2011

Session in cake php

The CakePHP session component provides a way to persist client data between page requests. It acts as a wrapper for the $_SESSION as well as providing convenience methods for several $_SESSION related functions.

Syntex for write session is :
     $this->Session->write('variable','value');

Syntex for check session is set or not (it gives true or false value) :-
     if(isset('$_SESSION'))
    {........}
If there are more then one session running ,then check session according to variable's value :-
     if($_SESSION['variable'] == 'value')   
     {.....}

If you wish to delete some session data, you can use the unset() or the destroy() function.
The unset() function is used to free the specified session variable:
     unset($_SESSION('variable'));

You can also completely destroy the all the running session by calling destroy() function:
     $this->session->destroy();