Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3300488
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:40:02+00:00 2026-05-17T20:40:02+00:00

// javascript for ajax pagination// document.observe(dom:loaded, function() { // the element in which we

  • 0
// javascript for ajax pagination//

document.observe("dom:loaded", function() {
  // the element in which we will observe all clicks and capture
  // ones originating from pagination links
  var container = $(document.body)

  if (container) {
    var img = new Image
    img.src = '/images/spinner.gif'

    function createSpinner() {
      return new Element('img', { src: img.src, 'class': 'spinner' })
    }

    container.observe('click', function(e) {
      var el = e.element()
      if (el.match('.pagination a')) {
        el.up('.pagination').insert(createSpinner())
        new Ajax.Request(el.href, { method: 'get' })
        e.stop()
      }
    })
 }
})

Why is this script inserting two spinner images?

here is the html

 <div style="margin-top:25px;">
      <div class="pagination ajax">
           <span class="disabled prev_page">&laquo; Previous</span> 
           <span class="current">1</span> 
           <a href="/posts?page=2" rel="next">2</a> 
           <a href="/posts?page=3">3</a> 
           <a href="/posts?page=2" class="next_page" rel="next">Next &raquo;</a>
      </div>
      <br style="clear:both;"/>
 </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:40:03+00:00Added an answer on May 17, 2026 at 8:40 pm

    I ran the javascript through jslint and fixed all errors but new Ajax. I moved the createSpinner-function since it’s not advisable to define it inside a block. Also the declaration of img was moved, semicolons added, and line-breaks to make the code more readable. (I have not tested the code, just “beautified” it)

    document.observe(
      "dom:loaded",
      function() {
        var img;
        function createSpinner() {
          return new Element('img', { src: img.src, 'class': 'spinner' });
        }
    
        // the element in which we will observe all clicks and capture
        // ones originating from pagination links
        var container = $(document.body);
    
        if (container) {
          img = new Image( );
          img.src = '/images/spinner.gif';
    
          container.observe(
            'click',
            function(e) {
              var el = e.element();
              if (el.match('.pagination a')) {
                el.up('.pagination').insert(createSpinner());
                new Ajax.Request(el.href, { method: 'get' });
                e.stop();
              }
            }
          );
        }
      }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I executing a function like this, <script type=text/javascript> $(document).ready(function() { getEntities(Clients/GetClients, 0, formatClientsResult); var
I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX
I've tried my best to be a purist with my usage of Javascript/Ajax techniques,
I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: {
I have a three-step process that is entirely reliant upon JavaScript and Ajax to
I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP
I need a JavaScript library that supports Ajax as well as help me in
I have coded some JavaScript to perform an ajax call in an asp.net application.
Is it possible to disable AJAX without disabling JavaScript completely?
I need to replace our Ajax Modal Popup controls with a JavaScript equivalent. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.