Hi all,
I have a problem thats bugging me, as its occuring very infrequent and
don''t know exactly whats the reason?.
I have static site that uses ajax to update the page content. When a
menu item on the left is clicked the content on the right is updated
through ajax. Now this works fine all the time in my local development
env. but when I deploy on a remote demo server, it starts causing the
problem, although it occurs *very* infrequent. The response is not
recieved on my page and my browser seems to hang. After some time it
again works fine.
Belows is code snippet, can anyone review this and tell me if anything
is wrong. I think the problem is regarding too many requests made,
causing too many objects created. Is there any way to free up the
memory?? However I have code to check the too many requests, still the
problem persists.
============= Below is the sample code snippet ===========
var globalEventHandlers = {
onCreate: function(){
Element.show(''loadprogress'');
},
onComplete: function(){
if(Ajax.activeRequestCount == 0){
Element.hide(''loadprogress'');
}
}
};
// register the handler
Ajax.Responders.register(globalEventHandlers);
function loadcontent(pagename,menuitem){
if(Ajax.activeRequestCount>=2){
alert("Too many requests made !");
return false;
}
var baseurl = "http://www.somesite.com/";
var url = baseurl + pagename + "?onlycontent=y";
var urlMenu = baseurl + "menu.php?onlycontent=y&menu="+menuitem;
var pars = "";
var ajaxObj= new Ajax.Request(url,{
asynchronus:true,
method: ''GET'',
parameters: pars,
onComplete: function(request){
writeContent(request,pagename);
},
onFailure: handleFailure,
onException: handleException
});
var ajaxObjMenu= new Ajax.Request(urlMenu,{
asynchronus:true,
method: ''GET'',
parameters: pars,
onComplete: function(request){
writeMenu(request,pagename);
},
onFailure: handleFailure,
onException: handleException
});
return false;
}
function handleFailure(request){
alert("Sorry, but some error occured. Please try again.");
}
function handleException(){
}
function writeMenu(request){
if(request.status==200){
$(''menu_area'').innerHTML = request.responseText;
}
}
function writeContent(request,pagename){
if(request.status==200){
new
Effect.Opacity(''content_area'',{durartion:0.5,from:1.0,to:0,
afterFinish:function(){
updateContent(request);
}}
);
}
}
function updateContent(request){
$("content_area").innerHTML = request.responseText;
new Effect.Opacity(''content_area'',
{
duration:0.5,
from:0,
to:1.0
});
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---