护照-Facebook Ajax错误

I am trying with passport-facebook ajax

client

$('#fb').click(function(){
         $.ajax({
           url:'/auth/facebook',
           type: 'post',
           success:function(data){
             if(data.result == true){
              ...
             }else{
               ...
             }
           },
           error:function(request,status,error){
                console.log("code:"+request.status+"
"+"message:"+request.responseText+"
"+"error:"+error);
           }
           })
    });

error message

XMLHttpRequest cannot load https://www.facebook.com/dialog/oauth?~~~

 ...

Response for preflight is invalid (redirect)

i don't know this error..

help me please

Facebook does not allow scripts to load the login dialog, i guess to prevent phishing. You need to do the GET request via the browser URL by an anchor tag. Or you can get around it in your AJAX by doing:

window.location.replace('http://yourdomain/auth/facebook')