• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Replace current html page with ajax response

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As David said, change what the server is returning.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic