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 6670145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:14:02+00:00 2026-05-26T03:14:02+00:00

How do I send this display_false() function to the server with jQuery so that

  • 0

How do I send this display_false() function to the server with jQuery so that the database is updated without refreshing the page?

    def display_false():
        if display == "false":
            main_id = self.request.get("main_id")
            k = Main.get_by_id(int(main_id))
            k.display = False
            k.put()

    display_false()    

First I hide a table row with this jQuery (see my previous question):

$(document).ready(function() {

    $("a.false").click(function(e) {
    $(this).closest("tr.hide").hide("slow");
    e.preventDefault();

});

and then I want to update the “display” property in the database to “false” with display_false()so that the item is not displayed.

And this is the html where the hide link is:

    for item in e:
        main_id = item.key().id()
        ...
        <tr class="hide">
        ...
        <a class="false" href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
        ...
        </td>
        </tr>
        ...

Thanks!

Update

This is what I tried according to Paul’s answer, but this is not working.

$(document).ready(function() {

    //hide the row
    $("a.false").click(function(e) {
    $(this).closest("tr.hide").hide("slow");
    e.preventDefault();


});

    $("a.false").click(function() {
    //ajax server call
    $.ajax({
    url: "/useradminpage?main_id=%s&display=false",
    success: function(data) {
    //do some stuff.
    display_false()
    alert('returned');
  }
});
});


});

Update

I put alerts to see what is running as suggested by Paul. Alerts 1, 2 and 3 are running but 4 is not running:

$(document).ready(function() {
    alert("1 - document ready is called")
    $("a.false").click(function(e) {
    $(this).closest("tr.hide").hide("slow");
    e.preventDefault();
    alert("2 - row is hidden")

});

    $("a.false").click(function() {
    //ajax server call
    alert("3 - ajax server call")
    $.ajax({
    url: "/useradminpage?main_id=%s&display=false",
    success: function(data) {
    //do some stuff.
    display_false()
    alert(4 - "returned");
  }
});
});


});

Update

This is the part of the code for that section of the table; I am trying to get the main_id and pass it to ajax call:

#-----------main table------------#

            main_id = self.request.get("main_id")

            self.response.out.write("""<table class="mytable">
            <tr class="head">
            <th  width="80%">links</th><th>edit tags</th>
            </tr>    
            """)        

            query = Main.all()
            query.filter("owner", user)
            query.filter("display", True)
            query.order("-date")
            cursor = self.request.get("cursor")
            if cursor: query.with_cursor(cursor)
            e = query.fetch(100)
            cursor = query.cursor()

            for item in e:
                main_id = item.key().id()
                self.response.out.write("""
                <tr class="hide">
                <td><a href="%s" target="_blank">%s</a><span class=small> (%s) </span><br />
                <span class=small>%s</span>
                <a href="/edit?main_id=%s"><span class="small">(edit)</span></a>
                <a class="false" href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
                <a href="/comment?main_id=%s"><span class="small">(comments)</span></a></td>
                <td><a href="/tc?url=%s&main_id=%s&user_tag_list=%s" title="edit tags">%s</a>
                </td>
                </tr>
                """ % tuple([item.url, item.title, urlparse(item.url).netloc,
                f1.truncate_at_space(item.pitch), main_id, main_id, main_id,
                item.url, main_id, (", ".join(item.tag_list)),
                (", ".join(item.tag_list)),]))

            self.response.out.write("""</tbody></table>""")    

            display = self.request.get("display")
            def display_false():
                if display == "false":
                    main_id = self.request.get("main_id")
                    k = Main.get_by_id(int(main_id))
                    k.display = False

                    k.put()

            display_false()    

Update after discussion with Paul to get the id number of the hidden row:

<script>

$(document).ready(function() {
    alert("1 - document ready is called")

    $("a.false").click(function(e) {
    $(this).closest("tr.hide").hide("slow");
    e.preventDefault();
    alert("2 - row is hidden")
});



    $("a.false").click(function() {

    alert(this.attr("title"));

    $.ajax({
    url: "/useradminpage?main_id=%s&display=false",

    success: function(data) {
    display_false()
    alert(4 - "returned");
  }
});
});
});


</script>
  • 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-26T03:14:02+00:00Added an answer on May 26, 2026 at 3:14 am

    You cannot update a server database with JQuery. All you can do is send a request that is handled by the server.

    Use JQuery.Ajax or any spin-offs of that function to send the request. To your server it will look as a regular request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I send this request to a page: http://www.server.com/show.xml?color=red&number=two Can I do something like
I have this jQuery function: $('#invite_friends_email').live('click' , function() { $(#invite_friends_email).dialog(); return false; }); and
How often do we see stuff like Send this page to a friend on
I need to send this XML <?xml version=1.0 encoding=UTF-8?> <gate> <country>NO</country> <accessNumber>1900</accessNumber> <senderNumber>1900</senderNumber> <targetNumber>4792267523</targetNumber>
In my sms-script I read in the text to send with this subroutine: my
i have form action file in another directory but some file send to this
Tag this with send-me-the-codez if you will. I've been asked to assist in putting
This question and answer shows how to send a file as a byte array
I get this: Warning: session_start(): Cannot send session cookie - headers already sent by
This post is incorrectly tagged 'send' since I cannot create new tags. I have

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.