By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,776 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,776 IT Pros & Developers. It's quick & easy.

Server-Side HTML to JavaScript Vars in AJAX?

P: n/a
Hello,
I am breaking my head running out of ideas about the best solution to
my goal.
I want to load some pages generated with the server (ASP) and assign
their html results to JavaScript, so users could click the links and
the content of any selected page would show up immediately, making no
requests.
So, I have one main page called mainpage.asp which, I think, should
get all subpages with content, names are subpage1.asp, subpage2.asp,
etc. I tried ASP's XMLHttpRequest to get content of all sub pages and
assign html result to JavaScript variables. But I realized that MS
XMLHttpRequest does not get session protected pages. I mean that if my
subpage will generate output with session only, then even if the
session exists, MS XMLHttpRequest does not see it.
Anyway, this trick did not work. If I include these subpages in
mainpage.asp under a hidden field, this may be a solution but I do not
see it good enough yet.
What would you recommend? How would you assign subpage's html code to
JavaScript variables or array of variables?
Thank you for ideas!

Mar 24 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ASM
vu******@gmail.com a écrit :
Hello,
I am breaking my head running out of ideas about the best solution to
my goal.
I want to load some pages generated with the server (ASP) and assign
their html results to JavaScript, so users could click the links and
the content of any selected page would show up immediately, making no
requests.
So, I have one main page called mainpage.asp which, I think, should
get all subpages with content, names are subpage1.asp, subpage2.asp,
etc. I tried ASP's XMLHttpRequest to get content of all sub pages and
assign html result to JavaScript variables. But I realized that MS
XMLHttpRequest does not get session protected pages. I mean that if my
subpage will generate output with session only, then even if the
session exists, MS XMLHttpRequest does not see it.
Anyway, this trick did not work. If I include these subpages in
mainpage.asp under a hidden field, this may be a solution but I do not
see it good enough yet.
What would you recommend? How would you assign subpage's html code to
JavaScript variables or array of variables?
Thank you for ideas!
If I understand well ... you want :

page A :
- content of page A visible
- content of page A_0 hidden
- content of page A_1 hidden
...
- content of page A_n hidden

that's to say to force user to download :
- almost a complete site
or at least
- pages he probably will not see

Do you really think it is a good idea ?

Why having sub-pages in JS variables ?
Can't they be in clear html ?
(in not displayed divs or objects)

If subpages html codes are in JS variables, when JS will use these
variables to write (or append) the html code, associated images will
have to be downloaded on this moment ... with call(s) to server and waiting.

So ... why not the powerful XMLHttpRequest ?

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 24 '07 #2

P: n/a
On Mar 24, 8:29 am, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
vunet...@gmail.com a écrit :
Hello,
I am breaking my head running out of ideas about the best solution to
my goal.
I want to load some pages generated with the server (ASP) and assign
their html results to JavaScript, so users could click the links and
the content of any selected page would show up immediately, making no
requests.
So, I have one main page called mainpage.asp which, I think, should
get all subpages with content, names are subpage1.asp, subpage2.asp,
etc. I tried ASP's XMLHttpRequest to get content of all sub pages and
assign html result to JavaScript variables. But I realized that MS
XMLHttpRequest does not get session protected pages. I mean that if my
subpage will generate output with session only, then even if the
session exists, MS XMLHttpRequest does not see it.
Anyway, this trick did not work. If I include these subpages in
mainpage.asp under a hidden field, this may be a solution but I do not
see it good enough yet.
What would you recommend? How would you assign subpage's html code to
JavaScript variables or array of variables?
Thank you for ideas!

If I understand well ... you want :

page A :
- content of page A visible
- content of page A_0 hidden
- content of page A_1 hidden
...
- content of page A_n hidden

that's to say to force user to download :
- almost a complete site
or at least
- pages he probably will not see

Do you really think it is a good idea ?

Why having sub-pages in JS variables ?
Can't they be in clear html ?
(in not displayed divs or objects)

If subpages html codes are in JS variables, when JS will use these
variables to write (or append) the html code, associated images will
have to be downloaded on this moment ... with call(s) to server and waiting.

So ... why not the powerful XMLHttpRequest ?

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
I guess you are right. Powerful XMLHttpRequest! You understood me
correctly. However, there are 4 tiny subpages I want to load only (not
the entire website). And the reason is that my whole website is not
AJAXed, but one section I could do in AJAX for user account
management, for example. Anyway, I do not want the half of my pages
will be regular links and half XMLHttpRequest. Instead, only one
management page will load all user account content with
XMLHttpRequest.
But how to store it and hide it? Huh? Use XML and parse it? So, there
will be HTML within XML? I am not sure...
Thanks for suggestions.

Mar 24 '07 #3

P: n/a
ASM
vu******@gmail.com a écrit :
On Mar 24, 8:29 am, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>So ... why not the powerful XMLHttpRequest ?

I guess you are right. Powerful XMLHttpRequest! You understood me
correctly. However, there are 4 tiny subpages I want to load only (not
the entire website). And the reason is that my whole website is not
AJAXed, but one section I could do in AJAX for user account
management, for example.

And what about hidden objects ?

http://stephane.moriaux.perso.wanado...ulti_pages.htm

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Mar 25 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more JavaScript / Ajax / DHTML Questions on Bytes