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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:54:12+00:00 2026-06-03T17:54:12+00:00

Here is my function: $(.link).click(function(event){ event.preventDefault(); event.stopPropagation(); pageLoad = $(this).data(‘page’); $(‘div#loading’).fadeIn(); $(‘div#content’).load(‘pages/’+pageLoad); }); I

  • 0

Here is my function:

$(".link").click(function(event){
    event.preventDefault();
    event.stopPropagation();
    pageLoad = $(this).data('page');
    $('div#loading').fadeIn();
    $('div#content').load('pages/'+pageLoad);
});

I have a div with the id content on my page which displays the called pages, however it seems to load the pages twice. I know this because one of the pages displays something in a shuffled order, and I can see it load twice.
Interestingly enough, it works fine when I add

throw new Error('something here');

to the end of the function like so:

// LINK CLICK
$(".link").click(function(event){
    event.preventDefault();
    event.stopPropagation();
    pageLoad = $(this).data('page');
    $('div#loading').fadeIn();
    $('div#content').load('pages/'+pageLoad);
    throw new Error('bla bla');
});

but anything else always causes it to fire twice. I tried rearranging things and so forth, but it still persists. My links that use this function are simple:

<a href="#" class="link" data-page="whatever.php">link</a>

Only one instance of jQuery 1.7.2 is being called. I am clueless as to what to do. I have also tried the live() and on() functions and experienced the exact same results.

!!! EDIT !!!

$(".link").click(function(event){
    event.preventDefault();
    event.stopPropagation();
    pageLoad = $(this).data('page');
    console.log('clicked');
    $('div#loading').fadeIn(function() {
        console.log('faded');
        $('div#content').load('pages/'+pageLoad+'.php', function() {
            console.log('loaded');
        });
    });
});

now… here is where this REALLY gets interesting. I did NOT change one of my links from

data-page="page.php"

to just

data-page="page"

(since the .php is now directly included in the function)

When I click any of links that should work as intended, I get loaded, clicked, then faded in my error console. Only one of each. The page loads twice. However, when I click on the link that shouldn’t work (because it contains the .php) IT STILL WORKS!! I get the three words and an error in my error console like so:

layout.js:25 clicked
layout.js:27 faded
jquery.min.js:4 GET pages/login1.php.php 404 (Not Found)
layout.js:29 loaded

but the page still loads in the content div EVERY TIME I click it, and it only loads once like it should…

So from what I have established here, there is some weird phenomenon occurring where jquery fetches page.php and page.php.php when I click the link

<a href="#" class="link" page="login1.php">

the proof is displayed when I try and fetch a page that isn’t even on my server using the following link:

<a href="#" class="link" data-page="no">no</a>

, where I am presented with 2 errors:

jquery.min.js:4 GET pages/no 404 (Not Found)
jquery.min.js:4 GET pages/no.php 404 (Not Found)

How is this even possible? Why would jquery be doing this? Can anyone even attempt to explain what is going on here?

  • 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-03T17:54:13+00:00Added an answer on June 3, 2026 at 5:54 pm

    The best way to find out why this happens (it does seem like you have tried to do all you can to prevent the event bubbling) is to set a breakpoint inside the click handler and check the stack trace up to that point.

    If it runs twice, on the second run you should get an idea why it was fired yet again.

    By throwing an exception I guess you’re break out of some jQuery loop.

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

Sidebar

Related Questions

Here is function , <script type=text/javascript> $(document).ready(function() { getRecordspage(1, 5); $(a.page-numbers).click(function() { alert(1); getRecordspage($(this).text(),
I have some JQuery Code as follows: $(#sh-zone-button-cart-menu).live(click, function(event) { event.preventDefault(); $(#sh-zone-cart-menu).toggle(0, function(){ if($(this).is(:visible)){
I wrote the function using js+jQuery. Here is a link to a jsFiddle which
$('#selector').click(function() { // here I would like to load a javascript file // let's
Consider this JavaScript code snippet: Object.prototype.log = function() { // here, you have a
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I'm trying to prevent the default anchor link and onclick event to trigger. Here's
I have this site: http://www.problemio.com and if you go there and click any link
I am using slideToggle to show some data in a div. Here's my code:
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new

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.