INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do You Terminate a Javascript Process

How do You Terminate a Javascript Process

(OP)
Hello,

I am using the following code to provide endless scrolling of content on my website. The code works fine and I have no problems with any of it with the exception of one minor thing. When I have no more results to display, the endless scrolling Javascript continues to activate and tries to load more results when the browser's scroll bar touches the bottom. Does anyone know how I can simply just terminate the javascript endless scrolling script once my classic ASP determines that there are no more results to load? I am guessing there is some sort of a "terminate all scripts" function or javascript routine I can use to just stop the infinite scrolling from executing in the current session?

Thanks for any help.



CODE -->

<html>
<head>
<style>
.wrdLatest {
position: relative;
display:block;
}

}
#lastPostsLoader {
text-align: right;
	width: 20px;
	margin: 125px auto 0 auto;

	
}

.centered {
  position: fixed;
  top: 50%;
  left: 50%;
  /* bring your own prefixes */
  transform: translate(-50%, -50%);
}
</style>
<script type="text/javascript" src="/scroll/jquery-1.2.6.pack.js"></script>
<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">

//Start Endless Scroll Script	
	
		$(document).ready(function(){
		
		$('form#mainForm').bind('submit', function(e){
			e.preventDefault();
			checkForm();
		});
		
		$('input#hostName').focus();
	


//Loading More content			
		function lastPostFunc() 
		{ 
			$('div#lastPostsLoader').html('<img class="centered" src="/scroll/rolling.gif">');
			$.post("/?thesearch=<%=thesearch%>&location=<%=location%>&action=getLastPosts&start="+$(".wrdLatest:last").attr("id"),
	
			function(data){
				if (data != "") {
				$(".wrdLatest:last").after(data);			
				}
				$('div#lastPostsLoader').empty();
			});
		};  
		
		
//Scroll Detection		
		$(window).scroll(function(){
			if  ($(window).scrollTop() == $(document).height() - $(window).height()){
			   lastPostFunc();
			}
		}); 
		
	});

</script>
</head>
<body>
' *** Very first set of results to be loaded and displayed:
<% If action <> getLastPosts Then %>
      <span>First Page of content. Enough content would be loaded in this area to where the user would have to scroll to see more </span>
      <% start = start + 25 %>
      <div class="wrdLatest" id="<%=start%>">
      <div id="lastPostsLoader"></div>
<% Else
   ' **** This is where more content would get added to the bottom of the previous page if the user's scrollbar touches the bottom  %>
       <span>Enough content would be loaded in this area to where the user would have to scroll down to see more content. </span>
       <span>If there isn't a lot of content here, then we want to simply just end the infinite scroll javascript and prevent it from executing if the user's scroll bar touches the bottom.</span>
       <% start = start + 25 %>
      <div class="wrdLatest" id="<%=start%>"></div>
<% End If %>

</body>
</html> 

RE: How do You Terminate a Javascript Process

Quote:

endless scrolling script once my classic ASP determines that there are no more results to load?

You can't, ASP scripts have completed and exited long before javascript even runs.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: How do You Terminate a Javascript Process

(OP)
Chris,

That is not my question. I am looking for a way to prevent SUBSEQUENT javascript from executing. This infinite scrolling actually uses Jquery. Jquery has a .stop() method. I just don't know how to properly use it for what I need.

RE: How do You Terminate a Javascript Process

basically javascript stops when it runs out of things to do.

{quote]That is not my question[/quote]

Are you sure? Because this;
{quote]Does anyone know how I can simply just terminate the javascript endless scrolling script once my classic ASP determines that there are no more results to load?[/quote]
Seems to be exactly what you were asking.

But to exit a javascript loop you use the break statement

I have no idea what a jquery stop() function does simply because I have never needed to use jquery for anything.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close