0
是否可以插入我的jQuery代碼到一堆javascript代碼我可以把jQuery代碼放在一堆純JavaScript代碼中嗎?
我想把$ajax
jQuery代碼爲function getInfo()
,但似乎不幹活嘗試換所有的JS代碼document.ready
但沒有太多的工作。
window.fbAsyncInit = function() {
FB.init({
appId: '201637766943985',
cookie: true,
xfbml: true,
version: 'v2.8'
});
FB.AppEvents.logPageView();
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
document.getElementById('status').innerHTML = 'We are connected.';
document.getElementById('fb_login').style.visibility = 'hidden';
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = 'We are not logged in.';
} else {
document.getElementById('status').innerHTML = 'You are not logged into Facebook';
}
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fb_login() {
FB.login(function(response) {
if (response.status === 'connected') {
document.getElementById('status').innerHTML = 'We are connected.';
document.getElementById('fb_login').style.visibility = 'hidden';
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = 'We are not logged in.';
} else {
document.getElementById('status').innerHTML = 'You are not logged into Facebook';
}
}, {
scope: 'email'
});
}
function getInfo() {
FB.api('/me', 'GET', {
fields: 'first_name,last_name,name,id,email'
}, function(response) {
////////call jquery AJAX here/////////////////////
});
}
function fb_logout() {
FB.logout(function() {
document.location.reload();
});
}
,你可以把你的純JS代碼中的jQuery代碼的想法。唯一的要求是您需要通過'