How to stop page from going to top after initial ajax request

I'm using jquery to initiate an ajax request that returns html. The problem is on the first click for each element that is hooked up to a click handler the page scrolls to the top, but on subsequent clicks it doesn't.

I'm using span tags with click handlers not links.

<span id="ratings" class="selected">ratings</span> $(function () { $('#ratings').click(function () { // ajax request that returns html $.ajax({ . ... .. success: function (msg) { $('AddHtmlToThisElement').html(msg.d); } }); }); });

-------------Problems Reply------------

return false at the end of your click function

Category:jquery Views:0 Time:2011-11-04
Tags: jquery

Related post

  • Ajax page, facebook's FB.init() causes all ajax requests to happen twice? 2010-11-30

    I have an ajax driven web app that uses some of the features of the facebook connect api. Once i've initiated facebook connect with: FB.init("my_key_here"); using <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib

  • HTTP Ajax Request via HTTPS Page 2010-10-27

    I am having a site with some pages on https connection. From these Https pages , i have to use a http ajax request for some errors retrieval like blank fields. But This error messages are not coming. Is there any solution to it or i have to make that

  • long running ajax request preventing page reload 2011-08-03

    I'm using jquery to make an ajax request to a controller method that can potentially take a while to return. The problem I'm having is that I can't reload the page until the ajax request finishes.. it just hangs until the controller method finishes a

  • jQuery Mobile AJAX Request while changing page 2011-12-13

    Using jQuery mobile, loading pages (internal pages) should be done by using an AJAX Request to load the document into the DOM. While an AJAX request is running (long-taking action on an SAP Server - Webservice) the application should stay responsive

  • How to cancel an ajax request in Django when new page is requested 2012-01-25

    In my web page (built on the Django platform), I have some jQuery that requests server data via an ajax request. How do I prevent the error function from executing when I click away from the page before the ajax request has responded. Here is my jQue

  • Remove form tag from remote page html fetched from ajax request 2012-02-09

    I want the HTML of remote aspx page to another page on which I am working with ajax request. I want the form tag removed from the remote page HTML also I want the+ scripts to be executed too which are on remote page. Remote Page: Test.aspx: <%@ Pa

  • Refresh page after AJAX request in jQuery Mobile 2012-04-03

    I have the following jQueryMobile page anatomy at index.html: <div data-role="page"> <div data-role="header">...</div> <div data-role="content">...</div> <div data-role="footer">...</div> </div> I'm int

  • asp.net page not returning ajax request 2013-02-18

    I am attempting to send an AJAX request from an ASP.NET Gridview row. Each row in the gridview shows completed jobs. Some jobs have files that can be downloaded. The end goal here is to show the download urls in a colorbox overlay, but I am having tr

  • In IE6, when I display a modal, a dropdownlist from the parent page is visible on top of the model 2009-04-16

    In IE6, when I display a modal, a dropdownlist from the parent page is visible on top of the model. i.e. the dropdownlist from the parent page is overlaying above the model popup. In firefox and IE 7 it is fine (the dropdownlist is tucked underneath

  • How can I prevent a page to jump to top position after failed validation? 2010-04-10

    I have a simple aspx page with a few TextBoxes and a submit button. Some fields are required and below the button is a ValidationSummary. The complete form is larger than screen height so one has to scroll down to reach the submit button. If I don't

  • PHP + Jquery - page move on top after an ajax call 2010-10-21

    I make this code that, after 9 seconds, it call an ajax function, and print the result elaborated from the server to the client. This is the JS code : function changeSponsor() { $.ajax({ type: 'POST', cache: false, url: './auth/ajax.php', data: 'id=c

  • Jquery UI Modal box makes page jump to the top on opening 2011-06-06

    I am currently using a Jquery ui modal box. When I am slightly scrolled down the page and click on the link to open the Modal box the box should open in the middle of the page, the modal opens in the correct position but makes the page scroll to the

  • jquery how to get the page's current screen top position? 2011-08-10

    jquery how to get the page's current screen top position? If I scroll my mouse wheel to some part of the page, how do I get the page's current top position? I want click one element in my page, then open a div which top is to current screen top. So j

  • Back button and backspace not working in IE on a page with a fixed top div and named links 2011-08-24

    Either the Back button nor backspace is working in IE on a page with a fixed top div and named links. Edit: I've clarified my problem with this updated code. Everything works fine in Chrome and Firefox but not in IE. <!DOCTYPE HTML PUBLIC "-//W3C/

  • Page jumps to the top when checkbox is clicked 2011-12-20

    I'm calling handleNotableTypeSelect method on the click of the check box, everything is working fine but the page jumps to the top. this.$hideInactiveCheckbox.click( this.handleNotableTypeSelect.createDelegate(this)); handleNotableTypeSelect: functio

  • IE11- Each page I go to with my mouse starts from the bottom of the page and not the top 2012-01-04

    Why does each page I go to with my mouse start from the bottom of the page and not the top? [Original title: Internet Explorer 11] --------------Solutions------------- Hi Deborah, I would like to have a better understanding before we start working on

  • After installing IE9,when I go to my hotmail page I see the top of my desktop above the Email. How can I eliminate this? 2012-02-02

    Original title: IE 9 After installing IE9,when I go to my hotmail page I see the top of my desktop above the Emai. How can I eliminate this? --------------Solutions------------- Hi, Could you please post a screen shot of the issue to help us assist y

  • why are the page tabs at the top of the screen 2012-03-14

    why are the page tabs at the top of the screen and whose stupid idea was that? I want them at the bottom where I can see them --------------Solutions------------- You can revert to your previous version if you want to:- http://windows.microsoft.com/e

  • Windows 7: Some web pages display words on top of each other! 2012-05-24

    I have an HP Pavillion dv7-4083 Entertainment notebook it came pre-installed with Windows 7. On some web pages some words or sentences are on top of each other making it very difficult to view content. I have tried clicking the broken page icon locat

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.169 (s). 11 q(s)