Monday, July 31, 2006

Javascript Prototype Library for AJAX - Synchronous Request

I am a big fan of Prototype library and using it for a while with excellent results for most of my AJAX work.

Most of the time i was making asynchronous request to get the response. Today i was trying to make a synchronous request using the following in my request page







<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script src="./src/js/prototype.js" type="text/javascript" >
</script>
<script language="JavaScript" type="text/javascript" >

function makeRequest() {
var myAjax = new Ajax.Request(
"testResponse.php",
{
method: 'post',
asynchronous: false,
onComplete: displayResponse
});
}

function displayResponse(xmlhttp)
{
alert("Am i coming here ");
xmlhttp = null;
}

</script>

</HEAD>

<BODY>
<table>
<Tr>
<td>
< href='javascript:makeRequest("abc")' >Click me
</a>
</td>
</tr>
</table>

</BODY>
</HTML>



My response page is simple php page echoing some message which is. testResponse.php is as under







<?php

echo "What i am sending from here";

?>



With this request setting for my AJAX call i.e. synchronous request is made with asynchronous request set to false. I am not able to fire onComplete method but when i change asynchronous request to true I am able to fire the function registered for my onComplete event.

Then i started looking in my livehttpheader whether request is getting fired at all or not. You guessed it right, request is not going from javascript.

I was not sure is it a bug in prototype library or I am doing something wrong. Later i found that i was passing parameters incorrectly. I have to change the way i was passing parameter i.e.

asynchronous: 'false'

and VOILA it works!!

So it was my editor which was showing keyword when it typed false without single quote and i have kept it like that :)

Wednesday, July 26, 2006

Ruby on Rails

I found this short and succint but complete presentation of what Ruby on Rails is. For beginners this is very useful to give them a head start.

Wednesday, July 19, 2006

Hellodeo - Voice message with expression

Hellodeo is an online video recorder with voice.

It is very simple to use. You just need a webcam and go to their homepage. It will detect your webcam and get permission to use your system resources (mic and USB port i.e. webcam) and then you record your video. Start recording and see it there itself after it is recorded and if liked it then submit it. It will be shown on their latest and greatest video and you will get a code snippet for your video. Here is my testing video.



I see multifold uses of this service -

  • Voice message along with video for anybody. You can then send this video via email, through home page, put it on your blog etc. While you are on vacation you can leave out on vacation video, welcome video on blog or homepage, demonstration of some product etc.

  • I would love to see this getting intergration in mobile devices. So it will be expression + voice message

  • Instant streaming of live event. I am not sure what is the maximum length of video that a user can record. But can be used to generate revenue



I liked this product and would try to use it and enhance this service or create something out of it. By the way did i tell you, i was thinking about it a month back but again I am late on designing and implementation.

Tuesday, July 11, 2006

Fix for z-index bug for IE 6.* (Select box is always on top)

Select boxes in IE are always on top of any other div or pop up windows or other elements. Even after setting z-index for select box as -1 and z-index for div tags which holds pop up window as 100 it does not work for IE.

Here is more about this bug.

http://blogs.msdn.com/ie/archive/2006/01/17/514076.aspx

They have fixed this error in IE 7 which is in beta version now.

Here is a work around or fix for this bug.

http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx

The fix works really well in IE and firefox (it was showing properly before also).

Fix for VBScript Error: Invalid procedure call or argument: 'Mid'

After long long time i have touched VBScript and was trying to traverse string character by character. I came across some weird error or may be i have not read VBScript for long long time.

When you try to traverse string character by character, never start with index 0 otherwise you will get the above error

Invalid procedure call or argument: 'Mid'

Along with this you will get argument 2 is invalid or something like that.

To traverse string character by character in VBScript use the following snippet of code:

/**

inputString = "String traversal in VBScript";
stringLength = len(inputString)

For i = 1 To stringLength
mychar = Mid(inputString, i, 1 )
WScript.Echo "My character is "+mychar
Next

*/

This is one of the way to traverse string in VBScript.

Sunday, July 09, 2006

India's march to become developed country

Tonight i came across this article by Michael Parekh a well known figure in blogosphere.

If above article interests you then you can read more about it here