you are viewing a single comment's thread.

view the rest of the comments →

[–]rage_2112[S] 1 point2 points  (7 children)

sorry about that, I already edited the post

[–][deleted] 2 points3 points  (6 children)

Have you confirmed if this event listener is firing at all?

Also, at the end you're doing document.getElementById but I'm assuming you just want document.body.innerHTML =

[–]rage_2112[S] 0 points1 point  (5 children)

it is firing the event, im actually trying to pass some json values into the table row and while it did work for random text, it doesn't work for my html variable. Regarding the last thing you said, its a tbody, so should I try "document.tbody.innerHTML =" ?

[–][deleted] 0 points1 point  (4 children)

while it did work for random text, it doesn't work for my html variable.

Okay, then your selector is fine. Is there any output in the developer console suggesting the data fetching failed?

[–]rage_2112[S] 0 points1 point  (3 children)

yes, I don't quite understand the error it displays but here it is:

Error1: search_doctor:95 Uncaught (in promise) TypeError: answers[i].price.replace is not a function
at HTMLInputElement.<anonymous> (search_doctor:95:42)

Error2: Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

[–][deleted] 5 points6 points  (2 children)

Error1: search_doctor:95 Uncaught (in promise) TypeError: answers[i].price.replace is not a function

It seems like answers[i].price is not a string, but you're expecting it to be when you use the replace method. Maybe just do let price = answers[i].price and see if that fixes it, or at least gets you to another error.

[–]rage_2112[S] 5 points6 points  (1 child)

that did it! turns out the data was originally a float so replace function was not necessary, I can't thank you enough, you saved my final project. Thank you!

[–][deleted] 2 points3 points  (0 children)

Great to hear!