Jump to ID after ajax form submit

I have the following form. After the search form is submitted and results are returned via an ajax call, I would like the page to jump to an ID - which happens to be the top of the results.

<form class="avail-form">
  ...
   <input type="submit" value="search" />
</form>

<div id="results">Results Found</div>
.
. Results
.

Current attempt that doesn't work.

$(document).ready(function() {
    $('form.avail-form').click(function() {
        $(this).scrollTop($('#results').offset().top);
    });
});

I tried using submit instead of click with no luck. I tried a bunch of different apporaches but can't seem to get it right.

Answers


Just change the hash when the request completes.

$.ajax({
    url: ...,
    success: function(){
        window.location.hash = "#results";
    }
});

Need Your Help

Issue with Checkboxes and Javascript, PHP

php javascript jquery mysql checkbox

I am struggling with the following PHP and JavaScript codes to have 2 sets of check-boxes filtering a range of data obtained from a MySQL database.

How do select the subsequent rows with the same attribute

xml xslt xslt-1.0

I am transforming from xml to xml between two different formats.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.