我正在使用第三方API來獲取值。例如,在這裏得到一個國家的價值就是樣本。JavaScript API不能在函數內工作
var _ttprofiles = _ttprofiles || [];
_ttprofiles.profiles = [];
_ttprofiles.push(['_sync', false]);
var callback = function(profiles) {
console.log(profiles.getCountry);
};
_ttprofiles.push(['_registerCallback', callback]);
_ttprofiles.push(['_enableServices']);
現在我很簡單地在這樣的JavaScript文件中使用。
var _ttprofiles = _ttprofiles || [];
_ttprofiles.profiles = [];
_ttprofiles.push(['_sync', false]);
var callback = function(profiles) {
console.log(profiles.getCountry);
};
_ttprofiles.push(['_registerCallback', callback]);
_ttprofiles.push(['_enableServices']);
(function() {
try {
// getValues();
} catch (err) {
}
})();
我在該國獲得價值。這裏1是我的螢火蟲
的屏幕快照但是,當我把這個方法中的,然後我得到空字符串
(function() {
try {
getValues();
} catch (err) {
}
})();
function getValues()
{
var _ttprofiles = _ttprofiles || [];
_ttprofiles.profiles = [];
_ttprofiles.push(['_sync', false]);
var callback = function(profiles) {
console.log(profiles.getCountry);
};
_ttprofiles.push(['_registerCallback', callback]);
_ttprofiles.push(['_enableServices']);
}
然後我得到空字符串,爲什麼?這裏是螢火蟲
的屏幕截圖,可以有人建議我的JavaScript調試好。我在Firefox中使用螢火蟲,但我的控制檯不工作我也嘗試鉻調試器,但它有同樣的問題,雖然控制檯的螢火蟲在鉻工作
似乎沒有要在這個問題上的信息足以讓一個有意義的答案。什麼是第三方API? 'profiles'從哪裏來? – TML 2014-09-24 04:58:40
我在我的索引頁中使用所以配置文件來自他們的 – Coder 2014-09-24 05:00:31
我不明白'var _ttprofiles = _ttprofiles || [];',從哪裏得到'_ttprofiles'? – 2014-09-24 05:01:14