答案必须明显,但我没有看到
这是我的javascript类:
var Authentification = function() {
this.jeton = "",
this.componentAvailable = false,
Authentification.ACCESS_MASTER = "http://localhost:1923",
isComponentAvailable = function() {
var alea = 100000*(Math.random());
$.ajax({
url: Authentification.ACCESS_MASTER + "/testcomposant?" + alea,
type: "POST",
success: function(data) {
echo(data);
},
error: function(message, status, errorThrown) {
alert(status);
alert(errorThrown);
}
});
return true;
};
};
Run Code Online (Sandbox Code Playgroud)
然后我实现了
var auth = new Authentification();
alert(Authentification.ACCESS_MASTER);
alert(auth.componentAvailable);
alert(auth.isComponentAvailable());
Run Code Online (Sandbox Code Playgroud)
除了最后一种方法,我可以达到一切,它在firebug中说:
auth.isComponentAvailable不是函数 ..但它是..
谢谢
dm0*_*514 15
isComponentAvailable没有附加到你的对象(即不是你的对象的属性),它只是被你的函数包围; 这使它变得私密.
你可以this在它前面添加它以使其成为pulbic
this.isComponentAvailable = function() {