• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Replace current html page with ajax response

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I 'm having a problem that I don't know how to deal with it. I want to make an ajax function, which polls for a server response.
Problem is that the response is dynamically constructed and the server returns an html page, which is either the wait page when
process has not yet completed, or the results page when process completes. I want to know, how can I show user the html page
returned to me. I tried using document.write but this does not seem to work. Here is the sample of the code I am using:

Thanks.
 
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the server going to give you the entire HTML response or you are concerned with content within the body tag alone. If it is just the body tag, you can give an ID to your current body tag and


 
Yiorgos Panayiotakis
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately I have to deal with the entire HTML response and not just the content. I have to replace the whole current html page with a
new one provided by the server.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd be better off returning a status code and a URL when you need to replace the entire page, and redirecting.
 
Yiorgos Panayiotakis
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is that I use the execAndWait interceptor of struts2, and I want to remove this annoying 'blink' effect that goes with using the
meta refresh tag. So for this purpose I do have to use Ajax to poll the server when the response is ready. Because the response is either
the wait page or the actual results when process completes, the status code is always 200. Also there is no URL, because response is generated
dynamically, only the data exist which I want to present to the user somehow.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As David said, change what the server is returning.
 
reply
    Bookmark Topic Watch Topic
  • New Topic