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

194
Views
Is it okay show some ids in html?

Is it okay to generate HTML page like this:

...
<div id='some_id' lesson_id='313'>
 ...
</div>
...

And in jQuery just do

lesson_id = $("#some_id").attr("lesson_id")
// send some AJAX POST requests with this lesson_id

Is it normal way to pass some data to js from server side ?

Many thanks!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use the data attributes:

<div id="some_id" data-lesson_id="313">

then in jQuery get the value:

var lesson_id = $('#some_id').data('lesson_id');

More about .data(): https://api.jquery.com/jquery.data/

over 4 years ago · Santiago Trujillo Report

0

So long as it doesn't reveal any major information that a malicious user can exploit, you can do that. As has been said, though, you should add the data-* attribute prefix, as this allows you to have custom HTML that's still considered valid.

over 4 years ago · Santiago Trujillo Report

0

Use jQuery Data

<div id='some_id' data-lessonid='313'>
 ...
</div>

lesson_id = $("#some_id").data("lessonid")
over 4 years ago · Santiago Trujillo 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!