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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:30:59+00:00 2026-06-17T16:30:59+00:00

I uses jQuery Ajax a lot to update a div in HTML pages. The

  • 0

I uses jQuery Ajax a lot to update a div in HTML pages. The ajax is included in $(document).read(…) such as the following:

$(document).ready(function() {
  $('a.button').click(function() {
    var url = $(this).attr('href');
    $('#content').load(url);
    return false;
  });
});

However, after clicking the button, Ajax sometimes fails and it displays the result in the whole page, instead in the ‘content’ div. This happened frequently when the page is loading or refreshed. But I suppose that $(document).ready(…) would prevent this from happening. What went wrong?

  • 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-17T16:31:00+00:00Added an answer on June 17, 2026 at 4:31 pm

    Ajax sometimes fails and it displays the result in the whole page

    This suggest that the hyperlink was not selected with the selector a.button. Make sure that the hyperlinks you want loaded via AJAX has the class name button, like so:

    <a class="button" href="...">
    

    If you want ALL hyperlinks to load via AJAX, remove the button selector.

    $(document).ready(function() {
      $('a').click(function() {
        ... ...
      });
    });
    

    If some hyperlinks are dynamically created after page load by another script, try this:

    $(document).ready(function() {
      $('body').on('click', 'a', function() {
        ... ...
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an jquery ajax success function which uses a template to put json
I want to make a form that uses jQuery's ajax function to submit the
I have two web pages; Foo.aspx and Bar.aspx. Bar.aspx uses jQuery.ajax() to request a
I have a web page that uses jquery ajax to grab the table markup
I am using the jquery form plugin which uses jquery ajax to do most
I use a jQuery plugin called jscroller, which uses jquery.ajax to make ajax calls.
Suppose I have a web application, which uses jQuery for Ajax and UI. Now
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I have code that uses jquery.slideup and jquery.slidedown How can i know that div
I have a data fetching method that uses jQuery.ajax() to fetch xml files. /*

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.