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

103
Views
establecer el valor para el elemento de etiqueta aspx de javascript

Estoy llamando a una API web usando javascript, tengo un elemento de etiqueta aspx con id "blbtest".

 <asp:Label ID="blbtest" Text="" runat="server ClientIDMode="Static">

Quiero almacenar el valor de la variable de nombre en esta etiqueta pero me sale un error

Este es el código js:

 var request = new XMLHttpRequest; request.open('GET', "https://hplussport.com/api/products?qty=2"); request.onload = function () { var response = request.response; var parsedData = JSON.parse(response); console.log(parsedData); var name = parsedData[0].name; var products = document.createElement('li'); //products.innerHTML = name; //document.body.appendChild(products); var lbl = document.getElementById('<%=blbtest.ClientID%>'); lbl.innerText = name; }; request.send();

El error: TypeError no detectado: no se pueden establecer las propiedades de nulo (configurando 'innerText') en XMLHttpRequest.request.onload (script.js:14:19)

Las líneas comentadas están funcionando. Pero quiero mostrar el nombre del producto en el elemento de la etiqueta cuando se carga la página.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Entonces, probé esto y funcionó :)

 document.getElementById('blbtest').innerHTML = name;
about 4 years ago · Juan Pablo Isaza 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!