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

158
Views
Estoy tratando de mostrar un párrafo de texto en HTML, pero necesito crearlo como un objeto JSON y leerlo con AJAX para hacerlo. mi codigo no funciona

He intentado iterar a través del objeto JSON pero no funciona. ¿Hay una forma más eficiente de estructurar el objeto? Además, no estoy seguro de que se esté realizando la solicitud AJAX porque sigo viendo un mensaje de error que dice "Hubo un problema: 0".

Este es mi archivo JS:

 $(document).ready(function() { $.ajax({ type: "GET", url: "lab4.json", dataType: "json", success: function(response){ var message = ""; $.each(responseData.text, function(i, item) { $.each(item.tutoring-text, function(x, s) { message += s; }); }); $("#tutoring-text").html(message); }, error: function(msg) { // there was a problem alert("There was a problem: " + msg.status + " " + msg.statusText); } }); });

Este es mi archivo JSON:

 { "text":{ "tutoring-text": [ "Gamma Nu Eta holds weekly tutoring sessions every Wednesday.", "At these tutoring sessions, GNH can help you with any course in your ITWS degree program.", "This includes ITWS core classes, such as Intro to ITWS and Web Systems, or classes outside of ITWS, such as Computer Science 1 and Data Structures.", "We can also help with any questions that you might have about career development, resumes, as well as just general questions about RPI." ] } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está intentando iterar cuando su estructura JSON es razonablemente plana.

Todo lo que realmente necesitas es

 $("#tutoring-text").html(response.text["tutoring-text"].join(""))
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!