Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3233218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:15:06+00:00 2026-05-17T17:15:06+00:00

I have an application(developed in python) that requires a refreshed view from the datastore

  • 0

I have an application(developed in python) that requires a refreshed view from the datastore after every 5 seconds. I have came out with an javascript function and handle the refresh using ajax.

Ajax function

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>      <script type="text/javascript">             var refreshId = setInterval(function()          {           $('#responsecontainer').fadeOut("slow").load('/refresh').fadeIn("slow");            }, 5000);       </script>

After which, I have a set of div tags(responsecontainer) that enclosed the parameters returned from the server side for display.

<div id="responsecontainer">
    {% for greeting in greetings %}
      {% if greeting.author %}
        <b>{{ greeting.author.nickname }}</b> wrote:
        <a href="/sign?key={{ greeting.key.id }}&auth={{ greeting.author.nickname }}">Delete</a>
      {% else %}
       An anonymous person wrote:
      {% endif %}
      <blockquote>{{ greeting.content|escape }}</blockquote>

    {% endfor %}
</div>

      <form action="/sign" method="post">
      <div><textarea name="content" rows="3" cols="60"></textarea></div>
      <div><input type="submit" value="Sign Guestbook" name="submitGuestBk"></div>

    </form>

My server side code is to query the datastore and render the result back to the template file(index.html).

class RefreshPage(webapp.RequestHandler):
  def get(self):
    greetings_query = Greeting.all().order('-date')
    greetings = greetings_query.fetch(10)

    if users.get_current_user():
      url = users.create_logout_url(self.request.uri)
      url_linktext = 'Logout'
    else:
      url = users.create_login_url(self.request.uri)
      url_linktext = 'Login'

    template_values = {
      'greetings': greetings,
      'url': url,
      'url_linktext': url_linktext,
      }

    path = os.path.join(os.path.dirname(__file__), 'index.html')
    self.response.out.write(template.render(path, {}))

However, when I run the application, the results got refreshed together with the html contents such as forms and tables. Together, I am seeing 2 forms after the index.html refreshed by itself every 5 seconds.

Can anybody guide me on the possible cause and solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:15:07+00:00Added an answer on May 17, 2026 at 5:15 pm

    The call to load('/refresh') replaces the contents of the responsecontainer div with the loaded HTML.

    You therefore need the RefreshPage handler to just return that HTML, and not the whole page. For example, it should use a template which just contains this:

    {% for greeting in greetings %} 
      {% if greeting.author %} 
        <b>{{ greeting.author.nickname }}</b> wrote: 
        <a href="/sign?key={{ greeting.key.id }}&auth={{ greeting.author.nickname }}">Delete</a> 
      {% else %} 
       An anonymous person wrote: 
      {% endif %} 
      <blockquote>{{ greeting.content|escape }}</blockquote> 
    {% endfor %} 
    

    To avoid duplicating that content in both templates, you could potentially make your main template include this sub-template inside the div, for example:

    <div id="responsecontainer"> 
        {% include "sub_template.html" %} 
    </div> 
    
    <form action="/sign" method="post"> 
    <div><textarea name="content" rows="3" cols="60"></textarea></div> 
    <div><input type="submit" value="Sign Guestbook" name="submitGuestBk"></div> 
    </form> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application developed with ASP.net and C# that is running on
I have an application that was developed for Linux x86 32 bits. There are
I imagine there are many of you out there who have developed an application
I have inherited a VB6/Access application that we have developed and sold for many
I have a web application developed in Adobe Flex 3 and Python 2.5 (deployed
I have developed application for drawing some shapes (lines mostly) , now i need
I have an ASP.NET application developed on my Vista box (IIS7). It works fine
I have a very nice MVC Beta application developed using VS2008 on a win2008
We currently have developed an application using WCF. Our clients make connections to different
I have an internal enterprise application I've developed for my company built on .Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.