jquery “load” for path contain spaces - Need help !

断了今生、忘了曾经 提交于 2019-11-29 02:20:37

You can "encodeURIComponent" your url:

$("#content").load(encodeURIComponent("uploads/flashes/New folder/target.php"));

Javascript encodeURIComponent method is equivalent to URLEncode.

You can use %20 to represent a space.

$("#content").load("uploads/flashes/New%20folder/target.php");

http://www.w3schools.com/TAGS/ref_urlencode.asp


EDIT:

If you don't want to do it manually, you could use encodeURI() instead. There are a number of common URI characters that it does not encode, which escape() will.

From the above answers, encodeURI() has worked fine with me. On the other hand, encodeURIComponent() has changed also the representation for the '/' character, with the result of not doing properly the HTTP request to the desired URL. So, I recommend to use the encodeURI() solution in the case that the path String includes '/'.

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