0

I try to make an AJAX requestin Chrome using the following code:

var url = "http://" + document.domain + "/status_data.lua?resetsessiontimeout=false";
xmlhttp.open("GET", url, true);
xmlhttp.send(null);

Using WireShark is see that send doesn't send anything... There is no GET emitted. But if I add an & at the end of the URL:

var url = "http://" + document.domain + "/status_data.lua?resetsessiontimeout=false&";
                                                                                   ^

then send will emit the GET request.

Is this expected?

4

1 回答 1

0

我将猜测人们(和我)犯的几个常见错误。

  1. 您是否创建了 xmlhttp 的实例?换句话说,您在上面的代码之前是否有一行“var xmlhttp = new XMLHttpRequest();” (区分大小写)

  2. 您是通过文件(如 C:/test.html)还是在网络服务器(如 Apache 或 jboss)上对此进行测试?如果你做前者,你会得到一个 Cross Point Origin 错误,而做后者会修复它。

  3. 您确定服务器代码在 resetsessiontimeout 后没有寻找其他变量吗?因为 '&' 用于分隔附加变量。尽管我很确定不需要结束变量。

就像我想用那个 url 发送一个错误字符串一样。我可以做 resetsessiontimeout=false&errmsg=test

于 2013-08-08T13:55:23.783 回答