Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2444
  • Last Modified:

Question on "onLoading" with Ajax.request in Prototype

I'm using the following code attached.  Basically I want to have a standard loading animation until the content is pulled down from the server and inserted into the DIV element.  Now, using actual javascript (aka not the prototype framework) i have no problems.  But I'd like to use the framework across this site, but when i use the code below sometimes my output hangs on the loading image.  Often if i click the button that calls this function twice, it'll act normally.  If i remove the onLoading code, the program functions normally.  I've been scratching my head over this and am running out of time  as I've never really used the onLoading aspect of Ajax.request before.  Any help would be appreciated
function showWindow(id) {
	var url = id+".php";
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
		   $('searchresults').innerHTML = transport.responseText;
		},
		onLoading: function(transport) {
			$('searchresults').innerHTML = "Loading...<img style=\"vertical-align:middle;\"src=\"/img/loading.gif\"/>";
		}
	});
 
}

Open in new window

0
dangereux
Asked:
dangereux
  • 2
  • 2
1 Solution
 
dangereuxAuthor Commented:
just read on the prototype site onLoading is "Not guaranteed", maybe this means "not working"
0
 
hieloCommented:
try:
function showWindow(id) { 
	 $('searchresults').innerHTML = "Loading...<img style=\"vertical-align:middle;\"src=\"/img/loading.gif\"/>";
      var url = id+".php";
      new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport) {
               $('searchresults').innerHTML = transport.responseText;
            }
      });
 
}

Open in new window

0
 
dangereuxAuthor Commented:
didn't even think about that, thanks
0
 
hieloCommented:
You are welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now