xmlhttprequest和查询字符串参数

时间:2011-01-25 22:22:09

标签: xml http

我想创建一个书签,它会从查询字符串中发送一个参数,例如author = John smith,然后将其插入到我的rails应用程序中,到目前为止我是否正确?提供我找到如何获取URL参数

function updateData(param) {
  var myurl = 'http://localhost:3000/app/book';

  http.open("GET", myurl + "?author=" + value-of-querystring-param, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);

}

1 个答案:

答案 0 :(得分:3)

看起来应该有效,假设useHttpResponse是处理函数。

您可能应该做的一件事是编码您的参数:

http.open("GET", myurl + "?author=" + encodeURIComponent(param), true);
相关问题