Recently I just faced some problem with Ajax implementation, here is an answer I found for the problem:
"When developing a traditional Web application you don't have to worry about encoding the form data because the Web browser performs this operation automatically when the user submits the data. In the case of an Ajax application, however, it's your job to encode the request parameters. JavaScript provides a very useful function named escape() that replaces any character that cannot be part of a URL with %HH where HH is the hexadecimal code. For example, any space character is replaced with %20."
The problem is very simple, when we make a http call to any url, we should encode the request parameters. I think I faced this similar problem when doing J2ME http call as well.
This code when make a http call, the result url will become:
http://www.abc.com/testing.asp?title=Title 1&content=Content body
Do you notice what problem with this url? Ya, the white space. From server side, the title & content text will received wrongly. (White space missing)
In order to correct it, we must add an encode function to replace the special text (white space) to "%20" or "+".
http://www.abc.com/testing.asp?title=Title+1&content=Content+body
http://www.abc.com/testing.asp?title=Title%201&content=Content%20body
Then only we can receive the correct text from the http call.
Another half day gone.
Here some special text that might be useful:
1) White space - %20
2) New line - %0D%0A (Windows), %0A (Unix), %0D (Macintosh)
3) "+" - %2B
4) "/" - %2F
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
Saturday, February 9, 2008
Saturday, February 2, 2008
Div Pop Up
Hehe, I finally find out how to pop up something without window frame.
Here are the examples of a normal window pop up & a div pop up which I want to implement soon.
Both example can be run when the code paste in a html extension file. This is what I called "Div Pop Up".
Here are the examples of a normal window pop up & a div pop up which I want to implement soon.
Both example can be run when the code paste in a html extension file. This is what I called "Div Pop Up".
Friday, February 1, 2008
Small Trick on IE7 with Ajax
Below is a javascript I wrote for Ajax call few days ago. This code run smoothly in Firefox, IE7 first call success, second call onward all fail.
Do you see what wrong on the above code? This code took me half day to debug, I was thinking is it IE7 browser bug or what. But in fact, the main reason it fail on IE7 is because IE7 make Ajax call very fast from second call onward.
The code haven't reach the set loading part already finish set result. Mistake learned.
Do you see what wrong on the above code? This code took me half day to debug, I was thinking is it IE7 browser bug or what. But in fact, the main reason it fail on IE7 is because IE7 make Ajax call very fast from second call onward.
The code haven't reach the set loading part already finish set result. Mistake learned.
Tuesday, January 15, 2008
J2SE 5.0 Enhanced for Loop
Here an example of J2SE 5.0 Enhanced for Loop by one of my old colleague:
This code maybe will run faster.
This code maybe will run faster.
Fiddler HTTP Debugger
Fiddler HTTP Debugger - A web debugging tool which commonly used by my colleague.
Today, I found a flash file (SWF extension) not loading a xml file correctly during my web development. So, I was thinking is it my false that putting the flash file in a wrong directory or there is some error on the flash file itself?
Suddenly, my colleague help me find out that it is the flash file problem, the xml file must put at a special path in order to make the flash work. It was Fiddler which help us trace which process calling which file at which path having problem.
Actually I had been teach by my colleague to use Fiddler before, but I just alway forgot to use it.
Anyway, here a Firefox Add-ons - Live HTTP Headers, something similar to Fiddler & it works well on Firefox browser.
Do remember to use it when you need it.
Today, I found a flash file (SWF extension) not loading a xml file correctly during my web development. So, I was thinking is it my false that putting the flash file in a wrong directory or there is some error on the flash file itself?
Suddenly, my colleague help me find out that it is the flash file problem, the xml file must put at a special path in order to make the flash work. It was Fiddler which help us trace which process calling which file at which path having problem.
Actually I had been teach by my colleague to use Fiddler before, but I just alway forgot to use it.
Anyway, here a Firefox Add-ons - Live HTTP Headers, something similar to Fiddler & it works well on Firefox browser.
Do remember to use it when you need it.
Thursday, January 10, 2008
Eclipse + Netbeans
I start switching from Netbeans to Eclipse. Reason of switching: company requirement.
"Code in Eclipse, build & run in Netbeans.", this is what I did on my first day using Eclipse because I have no idea how to run in Eclipse.
Well, I has been trying to use Eclipse from the past few days, I feel that this IDE is special for professional user. There are a lot of setting & plug in can be add. It really need some time for a developer to familiar with this IDE.
For a newbie on both IDE, Netbeans might be easier for them to learn up. Netbeans screen interface is more user friendly.
Although Netbeans 6.0 had released recently, but the overall speed still slower then Eclipse. Eclipse is more powerful on the debugging & find bugs features.
Overall, I still haven't familiar with Eclipse. Now I have to run both IDE, using Eclipse as the default IDE, Netbeans as my backup IDE in case I don't know how to use Eclipse.
"Code in Eclipse, build & run in Netbeans.", this is what I did on my first day using Eclipse because I have no idea how to run in Eclipse.
Well, I has been trying to use Eclipse from the past few days, I feel that this IDE is special for professional user. There are a lot of setting & plug in can be add. It really need some time for a developer to familiar with this IDE.
For a newbie on both IDE, Netbeans might be easier for them to learn up. Netbeans screen interface is more user friendly.
Although Netbeans 6.0 had released recently, but the overall speed still slower then Eclipse. Eclipse is more powerful on the debugging & find bugs features.
Overall, I still haven't familiar with Eclipse. Now I have to run both IDE, using Eclipse as the default IDE, Netbeans as my backup IDE in case I don't know how to use Eclipse.
Sunday, January 6, 2008
ASP.NET 2.0 Membership API
Today I was exploring on how to make a login form with ASP.NET & Ajax, then I come across few website that bring me to ASP.NET 2.0 Membership API.
Nowadays website require membership, user need to enter a username & password to login. Besides that, there are also roles for each user, something like admin user, super user or normal user. These two things are very hard to avoid, normally it is a requirement to implement.
All the above things can be done with ASP.NET 2.0 build in Membership API. It only require developer drag & drop few things, a simple website with login form done.
For this API, I do feel it is very useful, it save developer hundred of code to implement a login form with roles for each user. But when I start implement it, I feel very hard. The hard part is on their tag. Something like asking a developer who don't know HTML to make a website with Dreamweaver. I feel so uncontrollable on the login user detail:
1) How to login?
2) Login user detail stored where? Session? Cookie?
3) How to logout?
But in the end, I still choose to use this API, temporally able to login & logout. Maybe I need more time to read the tag documentation.
Nowadays website require membership, user need to enter a username & password to login. Besides that, there are also roles for each user, something like admin user, super user or normal user. These two things are very hard to avoid, normally it is a requirement to implement.
All the above things can be done with ASP.NET 2.0 build in Membership API. It only require developer drag & drop few things, a simple website with login form done.
For this API, I do feel it is very useful, it save developer hundred of code to implement a login form with roles for each user. But when I start implement it, I feel very hard. The hard part is on their tag. Something like asking a developer who don't know HTML to make a website with Dreamweaver. I feel so uncontrollable on the login user detail:
1) How to login?
2) Login user detail stored where? Session? Cookie?
3) How to logout?
But in the end, I still choose to use this API, temporally able to login & logout. Maybe I need more time to read the tag documentation.
Subscribe to:
Posts (Atom)