Wednesday, September 24, 2008
Enjoying working with cakePHP and Ext YUI for an interesting web application
As server side framework, I am using cakePHP and for the front side view yahoo javascript tools (Ext. YUI).
cakePHP: yes, makes easier all the area of PHP common coding.
Ext (YUI): Look ups are really beautiful. But, working is sort of complex for first time. Now I am really enjoying and solving all the problems and complexities of mine and my colleagues.
Friday, May 23, 2008
What is the difference between asynchronous (AJAX) and synchronous request?
Now-a-days, this is a very common question that been asked in all most every basic interview – What is the main strength of
But, the more perfect answer is – “
So, what is the difference?
In a word, a program does not wait for response after requesting an asynchronous call whereas synchronous does so.
Here is a simple example –
function check() {
var a=0;
a = getStatus(“getstatus.php?id=5”);
if(a==1) {
alert(“active”);
} else {
alert(“not active”);
}
}
Here getStatus() function sends a
But, this function will not work properly. It will alert “not active” instead of “active”. And yes, that is for the asynchronous request.
The reason is – when a = getStatus(“getstatus.php?id=5”); line is being executed program does not wait for the response of setStatus() function. So, value of keep unchanged or set to null.
So, how should we work with asynchronous request?
Of course, using callback function. Callback function is that function which is triggered when the request completes to get the response (or as defined).
Friday, May 2, 2008
Ajax cache problem for requesting same URL
Today my colleague, Al-Amin Rubel, faces a interesting (but very common of course) problem –
“Pages are not being reloaded/ refreshed after contents are updated by
After debugging a lot, it was clear that whenever request URL of
Solution:
So, perhaps the best solutions is to change the url every time. Don’t afraid, this is very simple, just add a url variable with random value using random() function.
Example:
Suppose, your
Then change it by adding a variable with random value – like
‘ajaxresponse.php?name=xyz&res=123&rnd=’+Math.random(10);
That’s it, solved!
This is because browser takes the url as a new request (url) every time.