Solved

Question on "onLoading" with Ajax.request in Prototype

Posted on 2008-06-20
4
2,384 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 82
How do i use the await event in php echo 5 44
Make Float not to Wrap 15 66
CSV export single column not inserting comma's in file 11 67
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

751 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