Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Question on "onLoading" with Ajax.request in Prototype

Posted on 2008-06-20
4
Medium Priority
?
2,412 Views
Last Modified: 2010-04-21
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
Comment
Question by:dangereux
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Author Comment

by:dangereux
ID: 21832489
just read on the prototype site onLoading is "Not guaranteed", maybe this means "not working"
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 21832715
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
 
LVL 3

Author Closing Comment

by:dangereux
ID: 31469218
didn't even think about that, thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 21832970
You are welcome!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question