XAJAX

03 Jun 2009

Basically using xajax “You can directly call php functions from your javascript code”

Xajax will do the rest. 

For example, if you are going to write a javascript function Capitalize which captilaze your textbox content when you press a button.

Here is the pure html/javascript code for that:

=============================================

<script>

function Capitalize()

{

      var t = document.getElementById(‘cap’).value;

      document.getElementById(‘update’).innerHTML = t.toUpperCase() ;

}

</script>

 

<input type=”text” id=”cap” name=”cap” />

<input type=”button” id=”capbutton” value=”Capitalize” onclick=”Capitalize()” />

<div id=”update”></div>

==============================================

Now see the difference when we use xajax, we can write this Capitalize function in php code and can call from javascript.

function Capitalize($value)

{

    $objResponse = new xajaxResponse();

    $objResponse->assign(“update”,”innerHTML”,strtoupper($value));

    return $objResponse;

}

and you can call from your button’s onclick function:

 onclick=”xajax_Capitalize(document.getElementById(‘cap’).value)” 

Here the same functionality we moved from client to server. Thus the point is you can simply call all the functions you written in php (Server Side) from javascript code via onClick, onMouseOver or window.onLoad etc.

You can get the full source code of Capitalize example here:

http://www.sajithmr.com/downloads/capitalize.zip

To download and for documentation go: 

http://xajaxproject.org/

Thanks

Sajith

Tags: , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Unix Tail Function

The most interesting and useful command i ever used is tail in unix. As the name indicate its duty is to show the last lines of a particular file. When take the case of log files such as error logs, always we have to know the last lines or last updations instead of reading from top to bottom or search a full text file.

for its option try this tail –help

tail -n 10 error.log

shows last 10 lines of error.log

The very interesting option is -f , means open the file and follow the last lines.

This is very useful for debugging purpose. For example if you want to check error.log lively, use this option

tail -f error.log

it displays last lines and also automatically updates when any changes happens in error.log file. So you can check other operation by tailing and following a particular file .

Try today itself. You will be very much interested, thats my guarantee :)

(There is also a similar function ‘head’, you can guess what its use, google it for more)

Regards

Sajith

Tags: , , , , , ,

· · · ◊ ◊ ◊ · · ·

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431