-1
私はJavaScriptを使ってクラスを作成しましたが、constructor
でAjaxリクエストを作成し、オブジェクト属性に戻りますが動作しません。どこが間違っている?Javascript/Jqueryで一度だけ必要なものがあります
class pergunta {
constructor(perguntas = [], respostas = [], desafios = [], valor = 100, posicao = 0){
this.perguntas = perguntas;
this.respostas = respostas;
this.desafios = desafios;
this.posicao = posicao;
this.valor = valor;
jQuery.ajax({
url: '../php/consulta.php' + location.search,
type: "GET",
dataType: 'json',
success: function(pergunta, desafio){
this.perguntas = pergunta.pergunta;
this.respostas = pergunta.resposta;
this.desafios = desafio.descricao;
}
});
}
}
const perguntas = new pergunta();
console.log(perguntas);
チェック'これはあなたの無名関数の中で何を意味しますか? – zerkms