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);
    
    评论

报告相同问题?