jQuery“加载"对于路径包含空格-需要帮助! [英] jquery "load" for path contain spaces - Need help !

查看:70
本文介绍了jQuery“加载"对于路径包含空格-需要帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在文件管理器中工作,以便在我的简单cms中使用,当jquery加载函数的路径包含空格时,我遇到了问题.有什么办法可以解决这个问题?

I'm working now in a file manager to be used in my simple cms and I have a problem in jquery load function when it takes a path contain spaces . is there any way to overcome this problem ?

    <script src="jquery.js"></script>

    <script>
        function get_content(){
            $("#content").load("uploads/flashes/New folder/target.php") ;
        }
    </script>

    <div id="content"></div>

推荐答案

您可以"encodeURIComponent"您的网址:

You can "encodeURIComponent" your url:

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

JavaScript encodeURIComponent方法等效于URLEncode.

Javascript encodeURIComponent method is equivalent to URLEncode.

这篇关于jQuery“加载"对于路径包含空格-需要帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆