Ajax判断数据大小的问题
<script type="text/javascript">
var xmlHttp;
function a(id){
var num=document.getElementById("num"+id).value;
var numbers=document.getElementById("numbers"+id).innerHTML;
alert(num+"num"+numbers);
try{
xmlHttp=new XMLHttpRequest();
}catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
alert("您的浏览器不支持AJAX!");
return false;}}
}
alert(num+"num"+numbers);
xmlHttp.onreadystatechange=callback;
if(num<numbers){
var url="../updatecartnumbers?id="+id+"&num="+num;
alert(url);
xmlHttp.open("post",url,true);
xmlHttp.send(null);
}else{
alert("请重新填写数量!");}
}
function callback(){
alert(xmlHttp.readyState);
if(xmlHttp.readyState==4){
alert(xmlHttp.status);
if(xmlHttp.status==200){
var txt=xmlHttp.responseText;
alert(txt);
var s= txt.split(",");
var id=s[2];
document.getElementById("total").innerHTML=s[0];
document.getElementById("numbers"+id).innerHTML=s[3];
document.getElementById("smallnum"+id).innerHTML=s[1];
}
}
}
</script>
当num大于100且numbers<100时,就不判断num<numbers了