후 jQuery를 아약스 호출을 처리하지 않습니다페이스 북에 연결 내가 다음 스크립트를 가지고 성공적으로 로그인
링크를 클릭<a href="#" id="fb-button">Login with facebook</a>
<div id="fb-root"></div>
, 팝업 :
<script>
window.fbAsyncInit = function() {
FB.init({ appId: '<%: Facebook.FacebookApplication.Current.AppId %>',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
function FBLogin() {
FB.login(function (response) {
if (response.authResponse) {
ConnectFacebookUser(response.authResponse.accessToken);
} else {
alert('User cancelled login or did not fully authorize.');
}
}, { scope: 'email' });
}
$('#fb-button').live('click', function (e) {
FBLogin();
e.preventDefault();
});
function ConnectFacebookUser(at) {
var postdata = "at=" + at;
alert('This is the access token : ' + at);
$.ajax({
type: "POST",
dataType: "json", // what data type to expect from the server
url: "/FBConnect.ashx",
data: postdata,
success: function (data) {
// do nothing
alert('all good');
},
error: function (xhr, status, error) {
alert('error occured in FBConnect.ashx');
}
});
alert('finished');
}
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
그리고 HTML 조각에 대한
페이스 북을위한 창이 나타나고 로그인 정보를 입력하면 "이것은 액세스 토큰입니다 ..."라고 말하지만 나머지 코드는 처리되지 않습니다. "페이스 북으로 로그인"링크를 한 번 더 클릭하면 모든 것이 정상적으로 처리됩니다.무엇이 문제 일 수 있습니까?
머리를 주셔서 감사합니다. 문제를 일으킨 ajaxStart 함수가있는 js 파일이 없습니다. 모두 잘 작동합니다. – gices