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 8624191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:27:48+00:00 2026-06-12T07:27:48+00:00

I added a simple voting feature to my website. For some reason, the ajax

  • 0

I added a simple voting feature to my website. For some reason, the ajax call resets the window scroll to the top of the page. This is obviously very annoying for the user as they have to start scrolling from the top each time they vote on a post.

I can’t seem to understand why it’s happening. Any suggestions?

function vote_up(post_id)
{
  //alert("Up: " + post_id);
  $.ajax({
  url: '<?php echo URL::base(); ?>voting_ajax.php?vote_up&post_id=' + post_id,
  dataType: 'json',
  success: function(data) {
      if(data.result == 1)
      {
        $('#up_count_'+post_id).html(data.vote_up);
        $('#down_count_'+post_id).html(data.vote_down);
      }
      if(data.msg != '')
      {
    $.msgbox(data.msg);
      }
    }
  });

}
  • 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-06-12T07:27:49+00:00Added an answer on June 12, 2026 at 7:27 am

    Do you have an empty ‘href’ or hash sign in your a tag such as

    <a href="#" onclick="action();">vote me up</a> ?

    If it is the case, the hash sign is what is scrolling up back to the top. You should use instead

    <a href="javascript:void(0);" onclick="action();">vote me up</a>

    Or have an event handler wich returns false as the default action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a simple .js file to my page that has some pretty
I added a simple ajax modal popup extender to my asp.net application. It appears
i added sprite to scene by this tutorials : http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 but i have bad
Simple. I created a LINQ-TO-SQL Entity model, created a website, added a Data Service
I've added some simple inoremap commands to my .vimrc to help with parens and
I've added a simple jquery slideDown function to a client's website but they want
I found this tutorial about how to build a simple voting system. I already
I have added a simple menu but its not showing up. this is menu.xml
Hi i just open new page in VS and added one simple line, question
I added some simple WatiN tests to our app today to check that a

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.