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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:14:43+00:00 2026-05-13T14:14:43+00:00

I’ve got a PHP page, with FedEx & UPS tracking numbers in a MySQL

  • 0

I’ve got a PHP page, with FedEx & UPS tracking numbers in a MySQL database echoing into ID’s of DIVs with the class “trackingnumber”. My JS each’s through those divs and grabs the ID to then post to a PHP page that polls Fedex/UPS and echos the result from them. That works great, except for one thing. It randomly deletes the data after it’s loaded it. So the data will flash on the screen for a second, and then disappear. It’s random too, which just baffles me. Check out this Video demonstrating the issue (.mov) to get a better understanding.

JS:

$(document).ready(function(){
    //Dislay some text indicating that we're getting status
    if ($("[id!='']")) {
        $("div.trackingnumber").html("working...");
    };
    //Begin getting status
    $('div.trackingnumber').each(function(index){
        var v2 = $(this).attr("id");
        //If it's FedEx, post to the FedEx script.
        if ($("[id!='1z'], [id!='1Z']")) {
            $.post("inc/fedex.php", { v: v2 }, function(data){
                $("#" + v2).html(data);
            });
        };
        //If it's UPS, post to the ups script.
        if ($("[id^='1z'], [id^='1Z']")) {
            $.post("inc/ups.php", { v: v2 }, function(data){
                $("#" + v2).html(data);
            });
        };
    });
});

Relevant HTML (after PHP has parsed it):

<td scope='col' width='100px'>
        <div class='trackingnumber' id='1ZX799380311650886'></div>
</td>

Any ideas? I’m new to jQuery (and JS in general)… I’ve got no idea why this is doing what it is. It looks like all my code is valid (the only errors in FireBug or Safari’s web inspector are when it hits a div without any data in the class)… I’ve been battling this for about a day now, finally getting it to this point… Really hoping someone will be able to help me out!

  • 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-13T14:14:43+00:00Added an answer on May 13, 2026 at 2:14 pm

    I’m afraid you’ve misunderstood how jQuery works; your if statements don’t make sense at all.

    $("[id!='']") will always return a jQuery object which, due to JavaScript’s automatic type coercion, will always evaluate to true. In other words $("[id!='']") == true no matter what your HTML looks like. The same applies for the rest of your if statements.

    Because of this mistake your code retrieves both the results of the UPS and FedEx scripts every time. Since the AJAX calls are asynchronous your results may appear in different orders thus causing an apparently random clearing of the data (when the empty data is returned after the correct data).

    This is how I assume you intended your code to behave:

    $(document).ready(function(){
      // Select all of the tracking numbers on the page
      $(".trackingnumber").
        // Display some text in each, indicating that we're getting status
        text("working...").
        // Begin getting status for each tracking number.
        each(function () {
          var trackingNumber = this.id;
    
          // Use the fedex script by default ...
          var script = "fedex";
    
          if (trackingNumber.match(/^1z/i)) {
            // ... unless it's a UPS tracking number.
            script = "ups";
          }
    
          $.post("inc/" + script + ".php", { v: trackingNumber }, function(data){
              $("#" + trackingNumber).html(data);
          });
        });
    });
    

    Working Demo: http://jsbin.com/iyeci (editable via http://jsbin.com/iyeci/edit)

    Don’t hesitate to ask if you need more help understanding the code.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yup. Measure-Command { .\do_something.ps1 } Note that one minor downside… May 16, 2026 at 12:30 pm
  • Editorial Team
    Editorial Team added an answer Given that you only know the type at execution time,… May 16, 2026 at 12:30 pm
  • Editorial Team
    Editorial Team added an answer I am not familiar with the control you mention, but… May 16, 2026 at 12:30 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

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
I have a JSP page retrieving data and when single or double quotes are
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.