Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, September 25, 2008

Some Javascript Tips

I have been doing a lot of JavaScript these days. Each day I learn newer things and each day I am starting to like it more and more.

I am going to compile a few queries where I broke my head.

Q) If I do window.open('anotherPage.html'), How can I change the DOM of the parent window.
This problem arrived when I was trying to add more rows to a table from another window itself.
Problem: Firefox allows it. But IE doesn't allow.
Solution: Use cloneNode() for FF. For IE , create the row again by attachRow()
Now for each cell, loop through it and do insertCells() and then copy the innerHTML to it.
All this is done in a simple loop through the table.

Q I have 3 frames on a page, I want to submit requests to page 2 and 3 at the same time
Do: document.forms[2].functionName();
yes, its as easy as this...
in your functionName(), you can add code to submit the form.submit();

Q Recursive Ajax calls.
Problem: To keep refreshing content of a page through Ajax.
One might typically use setInterval() but what if setInterval fires while a request from your ajax is coming back?
Solution: Use a global variable called "lock". Everytime you make a request set this lock, the call back function should release the lock.
When setInterval fires your ajax request function it should exit if its locked.

Q. getElementById('idname'). Don't use it too often, Try to traverse though the DOM by your code.

Q. Always give IDs to your form. Someday you'll find that this is very useful. You can submit a form from anywhere if you do this by getting the refrence of the form and then yourform.submit()

Q. Try to avoid excess IDs, This will occupy more browser memory interms of DOM parsing.
For example, If you have a table, don't give ID to each row. instead give the id to the table and then traverse the table.

Q. Do overuse Ajax and submit multiple requests simultaneously. Browser might allow this, but your database will not. Specially when you're doing connection pooling. In connection pooling , you have the same connection object and multiple execution of sql queries on the same object from different clients will result in failed transactions.

Q. attaching events is a good idea , but beware, IE and FF behaves differently. The API is completely different.

Q. Always use a common Javascript Browser detection Module. Make the detected browser global and then customize your scripts that way.

Q. Often while debugging we use alert("debug msg here.."); and waste time in commenting and uncommenting it. Instead use a global variable called "debug=true". And use if (debug) alert("");
You wont have to comment or uncomment it all the time.

Q. There are some good Javascript debuggers. Use them. The simplest one is FF error console. But what about IE? Yes, now you can use FF error console to debug IE related Errors too.. Install the FF IE tab plugin and have fun.

Q. Another great FF extension is Firebug. MUST MUST have for all you JS guys....

Saturday, February 16, 2008

Barcamp Pune 4

"Barcamp Pune 4: Love for technology" took place today at Thoughtworks Pune.
I gave a workshop on PHP & Ajax along with Priyank. This time I didn't develop any website but rather a Proxy server using PHP!
We also conducted a BOF session on PHP and Ajax Security and Meta Trader the online forex platform.

Get some pics here:

Barcamp Pune 4 Logo


PHP & Ajax workshop



Barcamp schedule.


Preparing for workshop

Slides and Video to come next..

Saturday, February 9, 2008

Gnunify 2008 Pics 1


Rush to get inside my workshop I

Rush to get inside my workshop II





Thursday, October 11, 2007

WebOSS '07 : The Web Technology Conference

WebOSS 07

The first of its kind Web Technology Conference on Open Source Technologies, WEBOSS ‘07 is being organised in Kolkata on Saturday 13th October, 2007.

I am the organizer and speaker.
The conference is going to be held at West Bengal University of Technology Main Campus.
Topics include: RIA, AJAX, ROR, PHP VS PERL, speeding up your websites. I'm going to speak on RIA and RoR.
There is also going to be a panel discussion on Web 1.0, Web 2.0 and Web 3.0.

Hope to catch some action!

Sunday, August 12, 2007

Bon Jovi Fan club

I have started a forum on Bon Jovi for their fans(I'm one).

There are some really die hard fans out there. The forum basically has two sections: 1) Bon Jovi the band 2) Bon Jovi Fans which have forums on General talks, Downloads, Music News. Apart from these, there are forums on RockTalk, Gossip, Polls and to top it all, Bon Jovi Vs Other Bands.

You can catch the site at: http://bonjovi.teks.co.in

There are 133 articles in just 2 days of its opening. Great start!

I will book the domain soon and keep you updated.