Server-Side HTML to JavaScript Vars in AJAX?

V

vunet.us

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!
 
A

ASM

(e-mail address removed) 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 ?
 
V

vunet.us

(e-mail address removed) a écrit :




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 ?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,087
Messages
2,570,600
Members
47,222
Latest member
jspanther

Latest Threads

Top