Here is my question,
Would it be possible, knowing that classic asp support server-side javascript, to be able to generate ‘server side HTML’ to send to the client like Response.write $(page).html()
Of course it would be great to use jQuery to do it because it’s easy to parse complicated structure and manipulate them.
The only problem I can think of that would prevent me from doing this would be that classic asp exposes only 3 objects (response, server, request) and none of them provide ‘dom building facilities’ like the one jQuery uses all the time. How could we possibly create a blank document object?
Edit : I have to agree with you that it’s definitely not a good idea performance wise. Let me explain why we would need it.
I am actually transforming various JSON feed into complicated, sometimes nested report in HTML. Client side it works really well, even with complicated set and long report.
However, some of our client would like to access the ‘formatted’ report using tools like EXCEL (using webquery which are depleted of any javascript). So in that particular case, I would need to be able to response.write the .html() content of what would be the jQuery work.
I such situations I use an XML DOM as surrogate for the HTML DOM I would have in a browser.
jQuery can manipulating an XML DOM however jQuery expects window to be present in its context. It may be possible to fool jQuery (or tweak it) so that it would work server-side but it could be quite fragile.
Personnally I just use a small library of helper functions that make manipulating an XML DOM a little less painful, For example as:-
Now your page code can do:-
As you create code that manipulates the DOM ‘in the raw’ you will see patterns you can re-factor as methods of the XmlWrapper class.