Questions tagged «prototype»

5
JavaScript类方法中未定义“ this”
我是JavaScript新手。就我真正完成的工作而言,新内容是对现有代码进行了调整,并编写了少量的jQuery。 现在,我试图编写一个带有属性和方法的“类”,但是我在使用方法时遇到了麻烦。我的代码: function Request(destination, stay_open) { this.state = "ready"; this.xhr = null; this.destination = destination; this.stay_open = stay_open; this.open = function(data) { this.xhr = $.ajax({ url: destination, success: this.handle_response, error: this.handle_failure, timeout: 100000000, data: data, dataType: 'json', }); }; /* snip... */ } Request.prototype.start = function() { if( this.stay_open == …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.