Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
La variable de clase JS no se configura

He creado una promesa AJAX y cuando está completa, estoy tratando de establecer una variable de clase, pero no está configurada por algún motivo. Pensé que se trataba de un problema ASYNC, pero la promesa debería haber resuelto ese problema. Es posible que sea un problema de alcance, pero no sé cómo resolverlo.

 $(document).ready(function(){ class Tables { constructor() { Tables.Action = this.GetAction() Tables.Headers = '' this.InitHeaders() console.log(Tables.Headers) //this.InitDatables() } GetAction() { var Segments = window.location.pathname.split("/") var URL = '/'+Segments[1] return URL } InitHeaders(){ this.GetHeaders().then(function(data) { // Run this when your request was successful Tables.Headers = data }).catch(function(err) { // Run this when promise was rejected via reject() console.log(err) }) } GetHeaders() { return new Promise(function(resolve, reject) { $.ajax({ url : Tables.Action +'/GetHeaders', success: function(data) { resolve(data) // Resolve promise and go to then() }, error: function(err) { reject(err) // Reject the promise and go to catch() } }) }); } } let Table = new Tables(); });
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!