Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
63 views
in Technique[技术] by (71.8m points)

javascript - Different value passed for cardnum begins with 0 in ajax

I notice as I'm trying to pass the value of cardnum, date and str to another page which is updatestaffshift page, and after echo the cardnum value, it appears to be a different value than the correct cardnum. However it only occur for cardnum begins with number 0. Numbers other than 0 the passing value is correct. I have included the output of my result. Please advice on what is wrong with this. Thank you.

function updatestaffshift(cardnum,date,str)
{
  var xmlhttp;    
  if (str=="")
  {
    document.getElementById("txtHint").innerHTML="";
    return;
  }
  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","updatedata/updatestaffshift.php?u="+str+"&cardnum"+cardnum+"&date="+date,true);
xmlhttp.send();

Echo card no

 $sql=" SELECT * FROM staff_detail";
 $query = mysqli_query($sql);  

 $int = 0;
 while ($rr = mysqli_fetch_assoc($query)){
 
 $cardnum[$int] = $rr['cardnum'];
 echo "Correct Card No :" ; echo $cardnum[$int]; 

updatestaffshift.php - Echo passed value

  echo 'Passed Value of Card No : '; echo $cardnum =  $_GET['cardnum'];

Output of result

enter image description here

question from:https://stackoverflow.com/questions/65904576/different-value-passed-for-cardnum-begins-with-0-in-ajax

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...