タグ付けされた質問 「prototype」

5
「this」はJavaScriptクラスのメソッドでは定義されていません
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 == …
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.