Display the ajax return data in a new window?

D

Dan

I have a question about the ajax return data.
How can I display the ajax return data in a new window?

When we use ajax, usually we update a <div>...</div>in the same page,
if i want to display the return data in a new window, how can i do
that? Many thanks for your help.
 
J

Jeremy J Starcher

I have a question about the ajax return data. How can I display the ajax
return data in a new window?

Reliably? You can't. With the number of very aggressive popup blockers,
and people who have new windows open as a tab, there is no way to ensure
opening a new window.
When we use ajax, usually we update a <div>...</div>in the same page, if
i want to display the return data in a new window, how can i do that?

I would strongly encourage you not to.
 
S

SAM

Le 12/3/08 11:08 PM, Dan a écrit :
I have a question about the ajax return data.
How can I display the ajax return data in a new window?

When we use ajax, usually we update a <div>...</div>in the same page,
if i want to display the return data in a new window, how can i do
that? Many thanks for your help.


why using Ajax for that ?

<form target="_blank" ...



if really and to try, perhaps something like :

function response () {
if(typeof truc == 'undenfined' || truc.closed)
truc = window.open();
truc.body.appendChild = XHR.responseText;
truc.focus();
}

not tested (popups are dead anyway)
 
D

David Mark

Le 12/3/08 11:08 PM, Dan a écrit :



why using Ajax for that ?

<form target="_blank" ...

if really and to try, perhaps something like :

function response () {
if(typeof truc == 'undenfined' || truc.closed)

SAM, what are we going to do with you?
truc = window.open();
truc.body.appendChild = XHR.responseText;
truc.focus();

8 million ways to die.
}

not tested (popups are dead anyway)

Yes and yes. But why post something like this? See the FAQ
concerning popup windows and enough with the fantasy code.

[snip]
 
D

Dan

Thanks for all help. Let me make my question more clear:

1. I have a jsp page. display a article in foreign language.
2. I call GOOGLE translation API, it is a ajax function and get the
translated results from this ajax call. All these are in
javascript.

3. I want to display the translated results in another window.(can be
a new tab or a new window)

How can I send the result data into the new page?


Otherwise, I think something like these:
when i hit the TRANSLATE link, the body of the article is sent to a
jsp page on server, then server receive the original
text, then send the translation request. My question is: if the
content of the article is not in a form, (e.g. they are in a <div>...</
div>,) can i POST the data to the server?

Thank you very much for all your help.
Dan


Le 12/3/08 11:08 PM, Dan a écrit :
why using Ajax for that ?
<form target="_blank" ...
if really and to try, perhaps something like :
function response () {
if(typeof truc == 'undenfined' || truc.closed)

SAM, what are we going to do with you?
truc = window.open();
truc.body.appendChild = XHR.responseText;
truc.focus();

8 million ways to die.


not tested (popups are dead anyway)

Yes and yes.  But why post something like this?  See the FAQ
concerning popup windows and enough with the fantasy code.

[snip]
 

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

Forum statistics

Threads
474,129
Messages
2,570,763
Members
47,324
Latest member
RicoBoxer

Latest Threads

Top