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

  • Home
  • SEARCH
  • 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 934147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:57:06+00:00 2026-05-15T20:57:06+00:00

I have this code, and for some reason my $.post function fires twice in

  • 0

I have this code, and for some reason my $.post function fires twice in quick succession (for ‘journal/weather’) according to Firebug. It still does this when I remove the “if (navigator.geolocation)”, however, if I replace the $.post block with something like console.log(‘test’), it only fires once.

What’s even weirder is when I place console.log(‘test’) before the $.post function, then my event only fires once as well. I am assuming something is going on strange with jQuery. Anybody have any ideas?

if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(function(position)
        {
        $.post('journal/weather', {latitude: position.coords.latitude, longitude: position.coords.longitude}, function(result)
            {
            if (typeof(result.current.temp) != 'undefined')
                {
                global.temperature = parseInt(result.current.temp, 10);
                global.temperature_slider.slider('value', global.temperature);
                }
            }, "json");
        });
    }

EDIT: Okay, stranger still, sometimes it fires twice, sometimes once. How can the same piece of code give different results each time it is executed?

EDIT 2: After some experimentation, I think this is a bug in Firefox. Why? Because it happens not only with my page, but others. If I keep refreshing my page, roughly the first 10 times the navigator.geolocation.getCurrentPosition fires the callback function. However, at a point, it quits doing so. And once it reaches this point, it doesn’t work for any other website that uses getCurrentPosition. And this problem never happens on Chrome or even IE. Searching Google, I found this:

http://groups.google.com/group/mozilla.feedback.firefox/browse_thread/thread/fecc3fb0bad6d0b8

  • 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-05-15T20:57:07+00:00Added an answer on May 15, 2026 at 8:57 pm

    It sounds like the code may be being called before the page is finished loading – hence console.log perhaps not yet being initialized.

    Is your code code wrapped in a document.ready of some sort, e.g.

    $(function () {
    if (navigator.geolocation) {
    …
    }
    });

    Just a guess. Would need to know more about the context in which the code appears to have a better stab at it.

    Hope that helps and good luck.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See http://codex.wordpress.org/Integrating_WordPress_with_Your_Website May 16, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer It appears that one of your requirements is that the… May 16, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer Row_Number() just returns a number in the list 1-5 so… May 16, 2026 at 12:16 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

For some reason I have to initialize the ListBox items in behind code, the
This syntax for some reason isn't working and I'm wondering why. When I alert
i'm using this code to post to a php page: var qreq = .....myurl.php;
I have my front end script which has the following jQuery code: $.get(/backend/post.php, {
Today while writing some Visual C++ code I have come across something which has
I'm placing content on my page through an ajax (post) request like so: $("input#ViewMore").click(function()
I have tried something like this in my Bison file... ReturnS: RETURN expression {printf(;)}
I have a WSDL generated by WCF and now this WSDL should be used
I having been running into some strange problems with a webpage that I have
I have the following HTML (excerpt from larger code-base) <div class=diary-event ui-corner-all title=[title]> <span

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.