Using xmlhttp.open() how do I add more than one parameter to url?

旧时模样 提交于 2019-12-08 05:00:55

问题


I have this code.

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

where q="+str

I want to pass a second var how do I do this?


回答1:


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

Note that this will not properly escape your parameters if they contains special characters. You might want to use something like encodeURIComponent(q) instead.




回答2:


Append + "&anotherVar=" + anotherString.



来源:https://stackoverflow.com/questions/3065981/using-xmlhttp-open-how-do-i-add-more-than-one-parameter-to-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!