可能重复:
jquery 从父级引用这个
这是我在此的头一篇博文。问题 - 如何从 ajax-success 调用警报?
var page = {
alerts: function (json) {
if (json == 'us') { alert("blablabla") } else {
alert(json.login);
}
},
ajax: function (obj) {
$.ajax({
type: 'post',
url: './scripts/serv.php',
dataType: 'json',
data: { object: $.base64.encode(JSON.stringify(obj)) },
success: function (json) {
// how to call from here alerts(json)?? this.alerts(json) - doesn't
// work only page.alerts(json) but i think its wrong way.
},
error: function (json) {
alert('ajax failed');
}
})
}
}