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!
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/
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.
Use jQuery Data
<div id='some_id' data-lessonid='313'>
...
</div>
lesson_id = $("#some_id").data("lessonid")