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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:23:57+00:00 2026-05-26T01:23:57+00:00

This is a follow up to my previous question (unresolved) . I fetch items

  • 0

This is a follow up to my previous question (unresolved).

I fetch items from the database and display them in a for loop. I use jQuery to hide one of the rows. Now I need to get the main_id of that hidden row and pass it to $.ajax. In the original question Paul suggested to use alert(this.attr("title")); but this line stops the execution of the $.ajax call and the call is not executed. When I comment out the alert alert(this.attr("title")); then the ajax call goes through. In that case, I get an error because the display_false() function in the handler does not get the value of the main_id.

This is the html of the “hide” link with title=%s.

<a class="false" title=%s href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>

So I need to pass the value of the main_id stored in alert(this.attr("title")); to the function display_false() when the ajax call is executed.

How can I do this?

The relevant code is below:

The Script

        self.response.out.write("""
<html>
<head>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" /> 
<title>User Admin Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<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("3 - ajax")
        //the following alert stops the ajax call from executing
        alert(this.attr("title"));

        $.ajax({
            url: "/useradminpage?main_id=%s&display=false",
            data: {main_id: "title"}
            success: function(data) {
            display_false()
            alert(4 - "returned");
            }
        });
    });
});


</script>
</head>
<body>
""")

HTML

#-----------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" title=%s 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, 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")
                    #I tried to get the "title" but this does not work
                    #main_id = self.request.get("title")
                    k = Main.get_by_id(int(main_id))
                    k.display = False                    
                    k.put()

            display_false()    
            ...

Update

Updated the code according to James Montagne’s answer (with a few changes). Now, for some reason, document ready is not loading, and the call to hide the row is not working, but ajax call to update the database is working. What am I doing wrong?

<script>

$(document).ready(function() {

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

    $("a.false").click(function() {
        alert("3 - ajax");

        $.ajax({
            url: "/useradminpage?main_id=%s&display=false",
            data: {main_id: "main_id", display: "display")},
            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-26T01:23:57+00:00Added an answer on May 26, 2026 at 1:23 am

    You don’t need to alert that value, you need to pass it. Currently you are passing the string title.

        $.ajax({
            url: "/useradminpage?main_id=%s&display=false",
            data: {main_id: this.attr("title")}
            success: function(data) {
            display_false()
            alert(4 - "returned");
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow on from my previous question although this is about something
All, this is a follow up from a previous question here: C# formatting external
This is something of a follow up from a previous question . The requirements
(This is a follow-up from this previous question ). I was able to successfully
This is a follow-on from a previous question, in the implementation, I have two
This is a follow-on from a previous question I had: How to decouple my
This is a follow up question from my previous one found here I need
this is a follow up question from my previous one. you can find it
This is a follow up question to a previous question I asked about calculating
This is a follow-up to a previous question I had about interfaces. I received

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.