11/15/2007
Lately I have been discussion with some of my coworkers what is the proper use of POST vs. GET server requests in AJAX web applications.
First let's look at the w3c recommendations:
"Use GET if: The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup)."
"Use POST if: The interaction is more like an order, or the interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or the user be held accountable for the results of the interaction."
In reality for simple to intermediate AJAX projects, both of these methods work pretty much the same. You call the server and get some data. The difficulty comes if the amount, or format of data you need send to the server gets too big. W3c states that "URIs cannot be longer than 256 characters." 256 can hold a lot of query string data, but what if you need to send more, or what if the format is not just set of ids, what if you want to be sanding XML formatted request, or even binary data? That's when POST comes handy. Why not using POST in all situations then? Well, because it is more complicated than GET, and for most of your requests GET will work just fine.
11/8/2007
While writing code for oznamkujucitele.cz, my first Czech web 2.0 portal, I needed to convert special Czech characters into standard English characters, so that I could put the Czech words into the URL. This was mainly for SEO purposes, so that the URL would have the right keywords. This happened to be a challenged. After looking around the web for some kind of out of the (Microsoft) box solution, or a piece of code that somebody wrote, I was forced to write this function myself. So here it is:
Public Function ConverChar(ByVal strCharString As String, ByVal strCharSet As String) As String
Dim arrCharSet(30)
Dim arrCharCouple(2)
Dim i As Int32
arrCharSet = Split(strCharSet, ",")
arrCharCouple = Split(arrCharSet(1), " ")
For i = 0 To arrCharSet.Length - 1
arrCharCouple = Split(arrCharSet(i), " ")
strCharString = Replace(strCharString, arrCharCouple(0), arrCharCouple(1))
Next
Return strCharString
End Function
Then in your webconfig file, create this reference that stores string with pairs of characters that you want to be replacing. Note that special characters cannot be contained in the code behind file (this will through an exception), so putting this string in your webconfig file or other xml file is a good idea.
<add key="tx_czech_charset"
value="Á A,á a,Č C,č c,ď d,é e,ě e,É E,Ě E,í i,Í
i,Ň N,ň n,Ó O,ó o,Ř R,ř r,Š S,š s,ť t,Ú U,ú u,Ů U,ů u,
Ý Y,ý y,Ž Z,ž z" />
11/5/2007
Q: What are the types of AJAX data formats and what are the advantages of using one over the other?
A: there are three types of responses: HTML, XML, and JSON.
HTML pros: good for simple apps because it does not require parsing.
HTML cons: some argue that this response does not separate data layer from presentation layer good enough
XML pros: is good because it’s a universal platform.
XML cons: requires parsing and is longer than JSON
JSON pros: it’s shorter than XML and is already in the same language that will be using it.
JSON cons: is sensitive to errors and requires more extensive knowledge of JavaScript.
11/5/2007
Just got back from the Hawaiian paradise like island Maui. When visiting places like this, I cannot help to think what would I have to do to live in a place like this. As a web developer, I hope that one day I will be able to do all my work remotely and live on Maui while maintaining my NYC corporate job. Anyway, enjoy the photos of Maui.
10/22/2007
Who in the world cares about web standards? I could not help doing this patriotic post. My home country (Czech Republic) scores in the number of searchers for XHTML and CSS2. This is even more significant considering the fact that the population of this country is only 30 times smaller than the US and 100 times smaller than countries like China or India.