对窗口进行编码时遇到问题.位置.href.

trouble encoding a window.location.href

本文关键字:遇到 问题 位置 href 编码 窗口      更新时间:2023-09-26

以下内容是URL中的空格重定向,我正在尝试使用encodeURIComponent将其删除。

谁能告诉我我做错了什么?

编辑:根据下面的建议,我正在发布整个脚本...

<script>        
window.fbAsyncInit = function() {
    FB.init({
        appId   : '<?php echo $AppID; ?>',
        oauth   : true,
        status  : true, // check login status
        cookie  : true, // enable cookies to allow the server to access the session
        xfbml   : true // parse XFBML
    });
  };
function fb_login(){
    FB.login(function(response) {
        if (response.authResponse) {
            FB.api('/me', function(response) {
                //Ajax Loader       
                     $.post("addtodb.php",
                     {name: response.name, email:response.email},
                        function(data) {
                        window.location.href = "next.php?name="+escape(response.name)+"&email="+(response.email); //redirect after post callback
                     })
            });
        } else {
        }
    }, {
        scope: 'email'
    }
    );
}
  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>
escape('foo bar');//foo%20bar
encodeURI('foo bar');//foo%20bar
encodeURIComponent('foo bar');//foo%20bar

这三个例子效果很好。如果没有,请检查 fi 代码上没有其他导致错误的内容或在此处发布整个脚本