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

  • Home
  • SEARCH
  • 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 8266163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:03:34+00:00 2026-06-08T05:03:34+00:00

I have a project wherein mongodb records are rendered in a browser via Flask.

  • 0

I have a project wherein mongodb records are rendered in a browser via Flask. I also have some interactions in the browser that would allow users to update records in the database. So, for instance, click a “Vote for me” link and you can increment a “vote” on the record. That record’s vote tally then would appear next to the “Vote for me link”.

Currently, however, my vote route looks like this, and I have to reload the page to update the vote tally in the browser:

@app.route('/vote_up/<this_record>')
def vote_up(this_record):

    vandalisms.update({'_id':bson.objectid.ObjectId(this_record)}, 
                  {"$inc" : { "votes": 1 }}, upsert=True)

    return redirect("/")

I’ve had a look at the flask documentation for jquery and flask here http://flask.pocoo.org/docs/patterns/jquery/ and understand what’s going on there, but don’t see how to extend that to the case where I want to update the mongodb collection first and then just reload a div or span specifying the new vote rendered from the updated record, e.g.

    <span id='vote_tally'> {{ item.votes }} </span>

What would I have to be doing to include that trip to the db and back to the browser without having to reload the entire page again?

  • 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-06-08T05:03:35+00:00Added an answer on June 8, 2026 at 5:03 am

    What I do is hook something like this to the click event:

    $('#vote_tally').load('/vote_up/3452/');
    

    Where the “ajax” url returns the HTML I want to modify.

    @app.route('/vote_up/<this_record>')
    def vote_up(this_record):
        if already_voted_for(this_record):
            return """<script type="text/javascript">
                           alert('You can only vote once');
                </script>{0}""".format(count_votes_for(this_record))
    
        vandalisms.update({'_id':bson.objectid.ObjectId(this_record)}, 
                  {"$inc" : { "votes": 1 }}, upsert=True)
    
        return count_votes_for(this_record)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application wherein I have some debug code that I do not
I have a web project wherein I have various functions that either add values
I have an interesting project wherein I need to allow users to capture video
I ran into a problem today at work wherein I have a BindingGroup that
I have a project that has to export images to PDF. Images and text
I have a maven project that I run using jetty: $ mvn run:jetty Where
I have a Ruby on Rails project that has been untouched for a while,
I have recently started on a PoC project wherein we are developing a small
I have added an Area to my Web project wherein I hope to perform
I have built a web setup project using VS 2008, wherein I need to

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.