Javascript 使用FF浏览器时未调用AJAX

Javascript 使用FF浏览器时未调用AJAX,javascript,ajax,facebook-graph-api,Javascript,Ajax,Facebook Graph Api,我正在完成此测试页: 当用户使用facebook登录时,系统应该调用ajax脚本。它发生在使用Chrome而不是Firefox时 以下是页面中的代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html> <head> <script type="text/jav

我正在完成此测试页:

当用户使用facebook登录时,系统应该调用ajax脚本。它发生在使用Chrome而不是Firefox时

以下是页面中的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html>
<head>

        <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '***REDACTED***']);
        _gaq.push(['_trackPageview']);

           (function() {
           var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
           ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
           var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
           })();
        </script>


    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="description" content="Live page for testing Facebook login and to learn how it works." />


    <title property="dc:title">Facebook Login Test Page - Come Hike</title>
    <link rel="shortcut icon" type="image/x-icon" href="http://www.comehike.com/img/ui/favicon.jpg">

    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.2r1/build/reset-fonts-grids/reset-fonts-grids.css&2.8.2r1/build/base/base-min.css">
    <link rel="stylesheet" type="text/css" href="../hike_layout.css"/>
    <link rel="stylesheet" type="text/css" href="../menusystem.css"/>

        <meta name="google-site-verification" content="RJcu8ObHW6huUbyea336xJ1WgLiC4478fz3_3r_zthc" />
        <meta name="alexaVerifyID" content="-2hEyu8phk6CFHF-PTqdQvP2B8k" />

        <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head>

<script type="javascript">
function loadfb()
{
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/es_EN/all.js';
    document.getElementById('fb-root').appendChild(e);
};
</script>

<!--<body onload="loadfb();">-->
 <body>








Array<br />
(<br />
    [OPENID_AUTH] => <br />
)<br />

<div id="fb-root"></div>

<script src="http://connect.facebook.net/en_US/all.js"></script>

<script>
  FB.init({
    appId  : '***REDACTED***',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true
  });

FB.Event.subscribe('auth.login',
function(response)
{alert("login");
    FB.getLoginStatus(function(response)
    {
        if (response.status == "connected")
        {
            FB.api('/me', function(response)
            {
//            alert ("First Name:" + response.first_name);
//            alert ("Last Name:" + response.last_name);
//            alert ("Email:" + response.email);
//            alert ("Location name:" + response.location.name);
//            alert ("Bio:" + response.bio);
//            alert ("Id:" + response.id);



// <img src="https://graph.facebook.com/FBNeedsADontLikeButton/picture"/>


              // Now need to go send an AJAX call :)
              var url="/auth/facebook_login_ajax.php?first_name="+response.first_name+"&email="+response.email+"&last_name="+response.last_name+"&bio="+response.bio+"&location="+response.location.name;
alert("sending request");
              var request = window.ActiveXObject ?
                  new ActiveXObject('Microsoft.XMLHTTP') :
                  new XMLHttpRequest;

              request.open("GET", url , true);

              request.onreadystatechange = function()
              {
                      if (request.readyState == 4)
                      {
                            var xmlDoc = request.responseXML;
                      }

                    location.reload(true);

              }
              request.send(null);

              // Check if the request was successfull and refresh the page
            });
        }
        else
        {
            // user not connected
        }
    });
});



FB.Event.subscribe('auth.logout',
function(response)
{alert("log-out");
    // Now need to go send an AJAX call to log out :)
    var url="/auth/facebook_logout_ajax.php";

    var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

    request.open("GET", url , true);

      request.onreadystatechange = function()
      {
              if (request.readyState == 4)
              {
                    var xmlDoc = request.responseXML;

                    // obtain the array of markers and loop through it
                    //result = xmlDoc.documentElement.getElementsByTagName("result");
              }
              location.reload(true);
      }
      request.send(null);



      // TODO: Check if the request was successfull and refresh the page

});
</script>


<div class="banner">
<!--  title and login/sign up go here -->
    <a href="/"><div class="site_title">Hike!</div></a>





           <div class="site_login">

    <fb:login-button show-faces="false" perms="user_about_me,email,user_location" autologoutlink="true" width="200" max-rows="1">
    </fb:login-button> |

           <a class="login_link" id="login" href="/auth/log_in.php">Log in</a> |
           <a href="/auth/create_profile.php">Sign up</a> |
           <a href="/auth/forgot_password.php">Forgot Password</a>
           </div>




</div>

<div class="nav_bar">
<!-- connect buttons and menu go here -->
    <div class="nav">
        <div class="icons">
<!--
            <div id="fb">
                <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
                <fb:like layout="button_count" show_faces="false"></fb:like>
            </div>
-->
<!--
            <div id="badge">
                <script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script>
            </div>
-->
<!--
            <div id="tweet">
                <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="comehike">Tweet</a>
                <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
            </div>
-->
        </div>

        <div class="menusystem" id="site_nav">
            <ul class="main_menu_ul">

                <li class="main_menu_li"><a href="/community/support.php">SUPPORT</a>
                </li>
                <li class="main_menu_li"><a href="/community/search_hikers.php?all=yes&redirect=yes">COMMUNITY</a>
                    <ul class="child_menu_ul">
                        <li class="first"><a href="/community/search_hikers.php">Search Hikers</a></li>
                        <li><a href="/hikes/search_hiking_groups.php">Search Groups</a></li>
                        <li class="last"><a href="/hikes/start_hiking_group.php">Start Regular Hiking Group</a></li>

                    </ul>
                </li>
                <li class="main_menu_li"><a href="/hikes/search_hikes.php?all=yes&when=f&redirect=yes">HIKES</a>
                    <ul class="child_menu_ul">
                        <li class="first"><a href="/hikes/schedule_hike.php">Start Single Hike</a></li>
                        <li><a href="/hikes/search_hikes.php">Search Hikes</a></li>
                        <li><a href="/hikes/search_hikes.php?when=b&redirect=yes&all=yes">Past Hikes</a></li>

                        <li><a href="http://www.comehike.com/outdoors/parks/add_trailhead.php">Add Routes You Know</a></li>
                        <li class="last"><a href="http://www.comehike.com/outdoors/parks/trailhead.php">Trailhead Map</a></li>
                    </ul>
                </li>
            </ul>
        </div>


    </div>

</div>

<!-- ************************************************* -->

<!--  the login overlay markup is hidden, will show if user clicks 'login' link -->

<div id="loginOverlay" class="yui3-overlay-loading" style="z-index: 100;">
    <div class="yui3-widget-hd"><h3>Login</h3></div>
    <div class="yui3-widget-bd">
        <div>
            <span>Email</span><input type="text" id="user_email"></input>

        </div>
        <div>
            <span>Password</span><input type="password" id="user_pass"></input>
        </div>
        <div id="err"></div>
    </div>
    <div class="yui3-widget-ft">
        <div class="btn" id="submit">Submit</div>

        <div class="btn" id="cancel">Cancel</div>
    </div>
</div>

<!-- ************************************************* -->

<!-- Main area of the page -->
<div id="layout2" class="content">
<div class="mainBody">
<div class="basic">
<p>
    <h1><center>Test For Facebook Login</h1></center>

</p>
</p>
<br />

<p>
<center>
<script type="text/javascript"><!--
google_ad_client = "***REDACTED***";
/* 728x90, created 12/23/10 */
google_ad_slot = "***REDACTED***";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</p>

<div class="footer">

    <p>Copyright (c) - 2011 Come Hike - All Rights Reserved |
        <a href="http://www.comehike.com/about_us.php">About Us</a>&nbsp;|
        <a href="http://www.comehike.com/contact_us.php">Contact Us</a>&nbsp;|
        <a href="http://www.comehike.com/privacy_policy.php">Privacy Policy</a>&nbsp;|
                <a href="http://www.nps.gov/index.htm">National Park Service Website</a>&nbsp;

    </p>
</div>  <!-- end footerdiv -->


<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
<script>
YUI().use('node','io','gallery-overlay-modal','event-key','json', function(Y){

    var LOGIN_URL = "/auth/auth.php";
    var LOGOUT_URL = "/auth/auth_logout.php";

    var dlg = false,
        elLogin = Y.all("a.login_link"),
        elLogout = Y.all("a.logout_link");

    var auth = function(){

        Y.one("#err").set('innerHTML', '<img src="/img/ui/ajax-loader-bar.gif" alt="Authenticating..."></img>');

        var u = Y.one("#user_email").get("value");
        var p = Y.one("#user_pass").get("value");
        Y.io(LOGIN_URL,
            {
                method:"POST",
                headers: {
                    'X-Transaction': 'POST 1'
                },
                data: "user_email=" + u + "&user_pass=" + p,
                on: {
                    success: function(id, o){
                        var o = Y.JSON.parse(o.responseText);
                        if(o.valid){
                            //dlg.hide();
                            window.location.reload();
                        }else{
                            if(o.error){
                                Y.one("#err").set('innerHTML', o.error);
                            }
                        }
                    },
                    failure: function(id, o){
                        Y.one("#err").set('innerHTML', "Authorization Error");
                    }
                }
            }
        );
    };

    var hideLogin = function(){
        if(dlg){
            dlg.hide();
        }
    };

    var onKey = function(e){
        switch (e.charCode) {
            case 13:
                e.preventDefault();
                auth();
                break;
            case 27:
                e.preventDefault();
                dlg.hide();
                break;
        }
    };

    var showLogin = function(e){
        e.preventDefault();
        if(dlg===false){
            dlg = new Y.Overlay({
                srcNode:"#loginOverlay",
                width:"25em",
                height:"17em"
            }).plug(Y.Plugin.OverlayModal);
            dlg.centered();
            dlg.render();
            var elSubmit = Y.one("#submit");
            if(elSubmit){
                elSubmit.on("click", auth);
            }
            var elCancel = Y.one("#cancel");
            if(elCancel){
                elCancel.on("click", hideLogin);
            }

            Y.on("key", onKey, "#loginOverlay");
        }
        Y.one("#user_email").set("value",'');
        Y.one("#user_pass").set("value",'');
        Y.one("#err").set('innerHTML', '');
        Y.one("#user_email").focus();
        dlg.show();
    };

    if(!Y.Lang.isNull(elLogin)){
        elLogin.on("click", showLogin);
    }

    var logout = function(e){
        e.preventDefault();
        Y.io(LOGOUT_URL,
            {
                method:"POST",
                data: "logout=true",
                headers: {
                    'X-Transaction': 'POST 2'
                },
                on: {
                    success: function(id, o){
                        window.location.reload();
                    },
                    failure: function(id, o){
                        window.location.reload();
                    }
                }
            }
        );
    };

    if(!Y.Lang.isNull(elLogout)){
        elLogout.on("click", logout);
    }


});
</script>
</div>  <!-- Closing basic -->
</div>  <!-- Closing main body  -->
</div>  <!-- Closing layout 2? -->

</div> <!-- Closing the body of this thing -->

</body>
</html>

var _gaq=_gaq | |[];
_gaq.push([''u setAccount','***编辑***']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement(“脚本”);ga.type=“text/javascript”;ga.async=true;
ga.src=(“https:==document.location.protocol?”https://ssl" : "http://www“+”。google analytics.com/ga.js”;
var s=document.getElementsByTagName(“脚本”)[0];s.parentNode.insertBefore(ga,s);
})();
Facebook登录测试页面-来吧
函数loadfb()
{
var e=document.createElement('script');e.async=true;
e、 src=document.location.protocol+'//connect.facebook.net/es_EN/all.js';
document.getElementById('fb-root').appendChild(e);
};
数组

[OPENID\u AUTH]=>
)
FB.init({ appId:“***修订版***”, 状态:true,//检查登录状态 cookie:true,//启用cookie以允许服务器访问会话 xfbml:对 }); FB.Event.subscribe('auth.login', 功能(响应) {警报(“登录”); FB.getLoginStatus(函数(响应) { 如果(response.status==“已连接”) { FB.api('/me',函数(响应) { //警报(“名字:+响应。名字”); //警报(“姓氏:”+响应。姓氏); //警报(“电子邮件:+回复.Email”); //警报(“位置名称:”+response.Location.name); //警报(“Bio:+response.Bio”); //警报(“Id:+response.Id”); // //现在需要发送一个AJAX调用:) var url=“/auth/facebook\u login\u ajax.php?first\u name=“+response.first\u name+”&email=“+response.email+”&last\u name=“+response.last\u name+”&bio=“+response.bio+”&location=“+response.location.name; 警报(“发送请求”); var请求=window.ActiveXObject? 新的ActiveXObject('Microsoft.XMLHTTP'): 新的XMLHttpRequest; 打开(“获取”,url,true); request.onreadystatechange=函数() { if(request.readyState==4) { var xmlDoc=request.responseXML; } 位置。重新加载(true); } 请求发送(空); //检查请求是否成功并刷新页面 }); } 其他的 { //用户未连接 } }); }); FB.Event.subscribe('auth.logout', 功能(响应) {警报(“注销”); //现在需要发送一个AJAX调用以注销:) var url=“/auth/facebook\u logout\u ajax.php”; var请求=window.ActiveXObject? 新的ActiveXObject('Microsoft.XMLHTTP'): 新的XMLHttpRequest; 打开(“获取”,url,true); request.onreadystatechange=函数() { if(request.readyState==4) { var xmlDoc=request.responseXML; //获取标记数组并循环遍历它 //结果=xmlDoc.documentElement.getElementsByTagName(“结果”); } 位置。重新加载(true); } 请求发送(空); //TODO:检查请求是否成功并刷新页面 }); | | |
登录 电子邮件 密码 提交 取消 Facebook登录测试


版权所有(c)-2011年-保留所有权利| | | |

YUI()。使用('node'、'io'、'gallery-overlay-modal'、'event-key'、'json',函数(Y){ var LOGIN_URL=“/auth/auth.php”; var LOGOUT_URL=“/auth/auth_LOGOUT.php”; var dlg=false, elLogin=Y.all(“a.login\u链接”), elLogout=Y.all(“a.logout_链接”); var auth=function(){ Y.one(“#err”).set('innerHTML',''; var u=Y.one(“用户电子邮件”)。获取(“价值”); var p=Y.one(“用户通行证”)。获取(“价值”); Y.io(登录地址), { 方法:“张贴”, 标题:{ “X-Transaction”:“POST 1” }, 数据:“user_email=“+u+”&user_pass=“+p, 关于:{ 成功:功能(id,o){ var o=Y.JSON.parse(o.responseText); 如果(o.有效){ //dlg.hide(); window.location.reload(); }否则{ if(o.error){ Y.one(“#err”).set('innerHTML',o.error); } } },
          request.open("GET", url , true);
          request.open("GET", url , false);