【发布时间】:2012-03-05 21:39:35
【问题描述】:
我希望 AJAX 回调触发 myFucntion 中的 alert() 并显示“它有效”,我如何在 ajaxResponse 中引用 myobject 对象?
function myobject() {
this.val = "worked";
http.onreadystatechange = function ajaxResponse() {
if (http.readyState == 4) {
this.myFunction();
}
http.send(null);
}
myobject.prototype.myFunction = function() {
alert("it "+this.val);
}
【问题讨论】:
-
我的问题是如何在 ajaxResponse 中调用 this.value 并引用包含此代码的对象中的值。
标签: javascript ajax oop