dswwuo1223 2016-04-15 03:18
浏览 44

Ajax响应文本始终为1

I am sending two variables to my php page for calculation then echoing the end result back. My response text always equals one.

The Javascript:

var xhttp = new XMLHttpRequest();
 xhttp.open("GET","calc.php?w1="+ftest+"&w2="+ltest,true);
    xhttp.onreadystatechange = function() {
     if(xhttp.readyState==4)   
     {   
         var dog = xhttp.responseText;
         alert(dog); 
     }   
    };
   xhttp.send(null);
  }

The php:

I set the end var to a random number here just to test if my math was causing the problem.

$startdate = $_GET['w1'];
$endDate = $_GET['w2'];
$workingdays = 239;
echo $workingDays;
  • 写回答

4条回答 默认 最新

  • dtgv52982 2016-04-15 03:24
    关注

    Set $workingDays directly to 10 ( random number ). If it is not 10, then you are clearly not seeing the result of that echo statement.

    1 is often used as the output to native PHP functions such as isset

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么