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

149
Views
Sending DOM element from client to server

I tried to clone a DOM object and send it to the server using socket.io and express, but after copying the element

( const element = document.getElementById('id').cloneNode; ) my server receives an empty object {}

and when i do console.log(element); on the client side everything works

(I send it into server by:

socket.on('document', (data, callback) => {
callback( document.getElementById(data[2]).cloneNode(true) );
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Socket.io converts objects to JSON to send over the wire. DOM elements have no properties that will convert to JSON.

const body = JSON.stringify(document.body);
console.log(body);

You'll need to copy the values you care about into a new object and convert any non-JSON data types into something that JSON can represent.

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!