Thursday, August 30, 2007

Orkut and AJAX code

I had ,of course even now , have lots of work more precisely lots of pressure these days in my team . so I had no time atleast think of posting here. Then , what triggered this post with my busy schedule always expecting me to be up there ?? Can you guess.... It's Orkut (Google aquired social comunity) .

Today morning, I just scribbled through one of the javascript communities in Orkut and in some thread I saw lots of users asking for some simple AJAX code to get started. I have jumped on the oppurtunity to make my name over there . I immediately started writing some AJAX code in bits and pieces from google and some other sources and finally arrived at some kinda output. Being satisfied with what I had done, started posting my content , to Orkut (as a reply to the thread I had mentioned) but in vain. To my sheer surprise, Orkut just don't allow more than 2048 characters to be posted as a reply for a thread. I can't even export my files to Orkut. Is there an option in Orkut I can export data to?? Surely not !!!. Then I had no other way , than posting the code in my personal blog (Thanks to Google acquired blogger) and then leaving a link to my blog in the orkut. By this time you could have understood why I had to go with this title for this post ;).

Now What's AJAX is?

AJAX - Asynchronous JavaScript and XML.
Ajax is asynchronous, this loading does not interfere with normal page loading. JavaScript is the programming language in which Ajax function calls are made. Data retrieved using the technique is commonly formatted using XML, as reflected in the naming of the XMLHttpRequest object from which Ajax is derived. hmmmmm .. you can find more here .

Code for a simple example. Ofcourse the javascript code is huge, but then, you can reuse the same code for any kind of application.

CODE:
1. test.jsp

Enclose the below javascript code with in the script tags and then write some html content to this jsp . Give a link using 'a' href tag to the javascript function call(). It should be (Remember I'm avoiding enclosing tags ) , < href="javascript:call()"> Clickthis .
Then have a DIV with id="postData" and style="display:block". DIV style="display:block" id="postData"> and close the DIV tag

SCRIPT code :

var rq = new Array();
var paramsArr = new Array();
function call()
{

getHtml('/postdata.jsp',"postData");
}

function getHtmlForForm(formElem,f, paramsObj) {
if(!paramsObj) {
paramsObj = '';
}
return getHtml(formElem.action,f, paramsObj, formElem);
}

function getHtml(url, fn, paramsObj, formElem) {
var xmlObject = null;
if( window.XMLHttpRequest ) {
xmlObject = getXmlObj(true);
} else if( !navigator.__ice_version && window.ActiveXObject ) {
//xmlObject = getXmlObj(formElem);
xmlObject = getXmlObj(true);

} else {
return false;
}

rt = rq.length
rq[rt] = xmlObject;
var paramsLen = paramsArr.length;
paramsArr[paramsLen] = paramsObj;
if (xmlObject) {
rq[rt].onreadystatechange = new Function( ' if (rq[' + rt +'].readyState==4) { ' + fn + '(rq[' + rt +'].responseText, paramsArr[' + paramsLen + ']) }');
if(formElem) {
handleForm(rq[rt], url, formElem);
} else {
rq[rt].open('GET', url, true);
rq[rt].setRequestHeader("Content-type","text/html");
rq[rt].setRequestHeader("Content-length", 0);
rq[rt].send(null);
}
}
return true;

}




//get XMLObject

function getXmlObj(formElem) {
var xmlObject = null;
if(document.all) {
var xmlObject = null;
if(!formElem) {
try {
xmlObject = new ActiveXObject('Microsoft.XMLDOM');
} catch(e) {}
}
if(xmlObject == null) {
try {
xmlObject = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {}
}
if(xmlObject == null) {
try {
xmlObject = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {
throw new Exception('Browser not supported');
}
}
} else {
xmlObject = new XMLHttpRequest();
}
return xmlObject;
}
function postData(result)
{
var msg = document.getElementById('postData');
msg.innerHTML =result;
showDiv('postData');
}
function showDiv(id)
{
document.getElementById(id).style.display='block';

}
//SCRIPT code ends here

2. The second JSP is the one to which we are making a ajax call and getting the content from that.

postData.jsp


Here, write some HTML code. It can be anything.


Now put both these jsp's under the same path and run the first one. Click on the link 'clickthis'. This will make a ajax call to the second jsp , fetch the content from that and show the content in the first jsp itself without the need of loading the page. Hope this helps the beginners. Please let me know if this is useful for you.

Saturday, July 21, 2007

TAJ MAHAL - TRIBUTE TO LOVE AND PASSION


The symbol for love and passion have made it again to the list of new wonders of the world.

For those who are not aware of Taj Mahal,

Taj Mahal was built by a muslim emperor Shah Jahan in the memory of his dear wife and queen Mumtaz at Agra, India. It is an expression of a 'dream', built out of white marble and standing in formally laid-out walled gardens, the Taj Mahal is regarded as the most perfect jewel of Muslim art in India.The emperor was consequently jailed and, it is said, could then only see the Taj Mahal out of his small cell window.

How many Shah Jahan's can you see in today's world ;) . I bet I will be one of them , if some xyz().. accepts my proposal ... he he.


A mention of new seven wonders of the world,
The Great Wall (Perseverance & Persistence) - China

Petra (Engineering & Protection) - Jordon

Christ Redeemer (Welcoming & Openness) - Brazil

Machu Picchu (Community & Dedication) - Peru

Chichén Itzá (
Worship & Knowledge) - Mexico

The Roman Colosseum (
Joy & Suffering) - Italy
The Taj Mahal (Love & Passion) - India











Friday, July 13, 2007

Yahoo - May I Suggest


Yahoo, one of the leading Web search providers have releasd their suggest search feature. I have tested this out and it's working pretty well. But, it’s sad that Yahoo always seems to be late to the party, because it's been a while Google released their suggest search with this and Y 's suggest is a bit slow compared to that of G 's.

What does this account for you?? Here is my piece,

  • For SEO operations its really useful. It is perhaps a way to find relavant keywords even better.
  • It will help people, search faster and more effectively.

When it's competition, you have to be right up there with your innovation . Hoping to see yahoo catch up with google.

Note: Yahoo's suggest search is not present in country specific yahoo sites .

Thursday, July 12, 2007

ZOHO Meeting : Create Meeting - Share Desktop and Chat

I have come across some Web conferencing application (Zohomeeting.com) recently , it is from the zoho suite of office appications. Zoho Meeting lets each member view (zoom in/out) and remotely control the host’s desktop, chat, add participants, email the host, and view meeting details. Chat is handled with Zoho chat (Hope to see VOIP capability in this area) . I'm really impressed with this , for the simple reason because NO Installations required from my part and setting up a meeting is as easy as 3 mouse clicks from my end. Well, here is a learning for all, make it simple for the user , he will surely love it and spread the word ! . It's me right now . I have had altleast 2 meetings a day for about a week now , with my friends in different parts of India and it worked just perfect. You can learn more from here, or here



Some of the pros and cons of zoho meet I have come across,

Pros:
  • Absolutely Free and amazingly fast
  • No Installations required
  • Setting up a meeting is very easy
Cons
  • The presenter has to be on windows.
  • Poor Control over remote(presenter's) machine. I mean , when I request for control over the remote machine, its taking loads and loads of time and integartion with zoho chat is pathetic .
Neverthless , these are still early days for Zoho and I wish them all the best.

Thursday, June 21, 2007

Site24x7 - Web site Monitoring Service

Recently I have been using some external web site monitoring service, site24x7 to monitor my blog .

 

The above stats show the last 7 days report of my blog . Well, I have a downtime of almost 2 min. and I have been notified through email and sms to my mobile. Thanks Site24x7.


 
Site24x7 provides you with two types of accounts, Free and Professional . Upon signing up they will give you a 15-day evaluation period and 10 free sms to test drive their site. After evaluation period , you will automatically be pushed to a Free account which lets you monitor 2 websites at 60 min. polling intervals. Professional account lets you monitor unlimited websites at any pollinterval starting from 5 min. . Professional account starts at $0.5/month/url(at 60 min. poll interval).

Well i cannot stop here , without giving a mention of their tools section which is been recently added. Site24x7 offers you a free set of tools .

1. Webpage Analyzer - This tool will show you the total page size, number of requests made and
the total time taken to retrieve a webpage. This tool is useful in finding
reasons behind slow pages. Personally, this is the tool I love.

2. DNS Lookup - This tool will do a dnslookup of your domain and gets you the Adress
records of your domain, Mail server records , Name server Records.

3. Find IP - Well if you want to find the ip of your webpage/ domain/ blog , its the
way to find it. Even I have to check out my IP before posting it here.

4. Find Location - Where is your Domain hosted?? Even I dont know where are the servers
behind this blog hosted before I encountered this tool.

5. Test Availability - Test your website /domain domain for availability, response time and some
header information.

SIVA PRATAP REDDY

Well if you ask me why I have this blog with my name in the title , then its for the search bots to make sure people who search for me, find me .

1. SSC: Nalanda English Medium High School, Kavali, AP.
Frnds -- Sivakrishna, Revendra, Sarath , Desu, Mani, Akbar, Naresh, Mahesh, Yasir .

2.INTER
: Sai Co-operative junio College, Kavali, AP
Some frnds here -- Firoz, Sankar Aditya( State first ranker) you can find this guy here or here
, Pradeep V, Ajay, Madhu, Murali, Ravi Sankar ..

3. Graduation (Electonics Instrumentation and Control Engineering)

N.B.K.R Institiute of Science and Technology
Frnds here -- Subba Naidu, Hari Krishna T, Hari Prasad, Venkat Reddy, Pratap, Chadrababu,Phani, Venu, Ramnaresh ..

Its been wonderful with you guys around.

Contact:
Presently working in chennai . You can always contact me at sivapratapreddyc[at]gmail[dot]com




Monday, June 04, 2007

Javascript Errors (IE and Firefox)

I normally come across some javascript errors during development in firefox , which it bypasses(I mean it allows the script to gothrough). But IE never allow you to go through with these js errors. One them is,

Error in parsing value for property " width " . Declaration Dropped . What's this error??

I had a tough time debugging this.

Suppose If you are changing the width of some property (say 'DIV' or 'table ' ) dynamically through your js, then you have to set it this way ,

... document.getElementById('DIV').style.width=" 20 px";

rather than ,

.. document.getElementById('DIV')
.style.width="20";

NOTE: Make sure that your width never goes negative . It wont work in IE. It will throw you some js error.


Google