【问题标题】:Using xmlhttp.open() how do I add more than one parameter to url?使用 xmlhttp.open() 如何向 url 添加多个参数?
【发布时间】:2010-06-17 22:01:10
【问题描述】:

我有这个代码。

xmlhttp.open("GET","getuser.php?q="+str,true);

where q="+str

我想传递第二个 var 我该怎么做?

【问题讨论】:

  • 我不知道那是什么意思。

标签: ajax variables get xmlhttprequest


【解决方案1】:
xmlhttp.open("GET","getuser.php?q=" + q + "&r=" + r, true);

请注意,如果参数包含特殊字符,这将无法正确转义您的参数。您可能想改用encodeURIComponent(q) 之类的东西。

【讨论】:

  • 老兄。这对我帮助很大。谢谢
【解决方案2】:

追加+ "&anotherVar=" + anotherString

【讨论】:

    猜你喜欢
    • 2011-04-01
    • 1970-01-01
    • 2019-07-04
    • 2012-05-01
    • 2010-10-03
    • 1970-01-01
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    相关资源
    最近更新 更多