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

166
Views
String is appending via Jquery.append but not with appendChild function

I'm converting a jQuery script into Javascript but appendChild is throwing error where jQuery was not. Below is the original code snippets

jQuery

if (data) {
  $('head').append(data);
}

Javascript

if (data) {
    document
      .getElementsByTagName("head")[0]
      .appendChild(data);
  }

error

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.

while data in has the following (JSON+LD) content

const data = "\n<script type=\"application/ld+json\">\n{\n  \"@context\": \"http://schema.org\",\n  \"@type\": \"BlogPosting\",\n  \"mainEntityOfPage\": {\n    \"@type\": \"WebPage\",\n    \"@id\": \"http://localhost:8080/?p=abbc\"\n  },\n  \"url\": \"http://localhost:8080/?p=abbc\",\n  \"headline\": \"How To workout.\",\n  \"datePublished\": \"2021-12-17T15:15:00-06:00\",\n  \"dateModified\": \"2022-05-31T11:01:15-05:00\",\n    \"author\": {\n    \"@type\": \"Person\",\n    \"name\": \"Laura\",\n    \"url\": \"http://localhost:8080/?a=laura\"\n  },\n      \"wordCount\": \"377\",\n  \"description\": \"Main description  . \"\n}\n</script>"
about 4 years ago · Juan Pablo Isaza
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!