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

298
Views
¿Cómo puedo convertir la cadena devuelta de la llamada API al HTML adecuado en javascript?

Estoy llamando a un command("@ReportProperty2(45899,exportdata,,'16115898')@") que devuelve el HTML del botón pero en formato de cadena y > y < están en &gt; y &lt; y hay comillas dobles que rompen mi código en la siguiente línea:

 const aaa = "@ReportProperty2(45899,exportdata,,'16115898')@";

RESULTADO DEL COMANDO:

 "&lt;button type=button class=Button onclick="openwp('1677008','RHpdFBx7GS9YGFEwFmUUCyE4Ih8lHyA!H2JbUENBa1BV')" &gt;&lt;i class="fa fa-pencil-square-o" style="margin: 0 4px 0 0"&gt;&lt;/i&gt;Enter Budget&lt;/button&gt;"

Intenté reemplazar pero arroja "unexpected token: identifier" error.

¿Cómo puedo convertir el resultado a lo siguiente:

 <button type="button" class="Button" onclick="openwp('1677008','RHpdFBx7GS9YGFEwFmUUCyE4Ih8lHyA!H2JbUENBa1BV')"> <i class="fa fa-pencil-square-o" style="margin: 0 4px 0 0" data-original-title="" title=""> </i> Enter Budget </button>

Por favor vea la foto para más información: ingrese la descripción de la imagen aquí

Probé Lodash unescape, decodeHTMLEntities de Slavik Meltser, decodeEntities pero no funciona.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Dependiendo de su motor de plantilla, puede haber un método más apropiado, pero suponiendo que esta salida @ se escape como HTML, puede ponerlo en un contexto HTML (no renderizado):

 <template id="aaa-html">@ReportProperty2(45899,exportdata,,'16115898')@</template>

Luego puede seleccionar el elemento y leerlo desde JavaScript:

 const aaa = document.getElementById('aaa-html').innerHTML;
about 4 years ago · Santiago Gelvez Report
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!