We help IT Professionals succeed at work.
Get Started

AJAX getting wrong page?

slightlyoff
slightlyoff asked
on
337 Views
Last Modified: 2015-06-08
I've never head of this happening before - I'm not quite sure exactly what is going on.  Unfortunately the page this is occurring on is an "Admin" page - and I can't provide a useful link for you to see the behavior.  I'll do my best to describe it.

I have a page that allows the user to put online items that are in stock.  When a user enters a SKU, using AJAX, i return a HTML form  generated and filled in from the DB by "hrgetSku.asp".  The user can also click on a list of products already in the "in-stock" list by clicking a link in a list.

My XML Code looks like this (it's old code, been working for the past several years...):

<script type="text/javascript">
function getBP()
{

var xmlhttp;
var sku;

sku = document.getElementById('theSKU').value;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET","hrgetSku.asp?sku="+sku,true);
xmlhttp.send();

return false;
}

function getEBP(aSku)
{

var xmlhttp;
var sku;

sku = aSku;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
//alert("here!");
xmlhttp.open("GET","hrgetSku.asp?sku="+sku,true);
xmlhttp.send();

return false;
}

Open in new window


When you click a link, you call the function like this:  <a onclick="getEBP('x4tte'); return false;" href="#">View x4tte</a>

You'll notice at the end of the getEBP() function there's an "alert('here')" commented out for testing purposes.
When I run my code (and the alert is uncommented out) - every link I click on works - I get the alert.  HOWEVER....

Some products seem to be pulling from an old or different "hrgetSku.asp" page.  I've made changes to "hrgetSku.asp" posted it, and for some products I see the change and for others i don't see the change.  As I mentioned earlier, "hrgetSKU.asp" returns a form that is filled in with the database.  To make sure the right page was getting called, I changed some titles on the form.  On most products the changes show up. On some, however, they don't - even though they are running through the same ajax and calling the same page.  Further - those products that don't show up don't pull all the data.  It's as if they are pulling a different hrgetSKU.asp page all together.  They are pulling some version of it, because it looks identical, minus my changes and missing data.

So this is very strange...  I even added the full "http://www.mywebsitehere.com/admin/hrgetSKU.asp" path to the hrgetSKU.asp page in my ajax code.  It still doesn't pull the file  with my changes.  I think Im going mad...

This is a difficult question to ask since I can't show you the behavior, but  I hope I've made clear what's going on.
Any help would be greatly appreciated!!!
Comment
Watch Question
Web Ninja at large
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 9 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE