weixin_33691817 2015-12-16 14:33 采纳率: 0%
浏览 220

向网址添加唯一的ID

I have some difficulty in understanding how to add an id to an url for sending a request to a server. In fact, my main problem is the position of quotation mark after the equal sign in the third open method. Why it is not used just after Math.random() or just after .asp. Since, if i place the quotation mark just after math.random(), it works but just before math.random() does not. I want to understand what the quotation mark changes here...

xhttp.open(method, url, async);
xhttp.send();

xhttp.open("GET", "demo_get.asp", true);
xhttp.send();

**xhttp.open("GET", "demo_get.asp?t=" + Math.random(), true);**
xhttp.send();

For example, I understand what is happening in the following url.

http://localhost/test.php?q=_&p1=_&p2=_

? lets the server know what the ?_GET variables start q, p1, and p2 are parameters and _ is value

  • 写回答

3条回答 默认 最新

  • weixin_33726943 2015-12-16 14:51
    关注

    The Math.random() function returns a float value. You are actually building up a string. So you need to convert it like so:

    xhttp.open("GET", "demo_get.asp?t=" + Math.random().toString(), true);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: