I am loading a Razor View via AJAX and putting the content into a div on a page.
If I want to send some arbitrary data from the view to our AJAX framework, is there a recommended HTML tag to do this with? A hidden field sounds like the wrong this to use for this. I could use an empty div with custom data- attributes, but again, a div sounds wrong.
My data isn’t relevant to any element within this view, more related to the view itself.
Yes – this is simply a question of systematics and aesthetics.
I use
data-*attributes, and try to find and attach them to already existing related elements. This convention is also used by asp.net mvc framework itself – when link target needs to be loaded,data-ajax-*is attached to anchors. When you need to set update target of form submit, you attachdata-ajax-*to form, so in most cases it is possible to find good candidate for it. If it is not possible in any particular case, I do not see problems usingbodyinstead.