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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:33:52+00:00 2026-06-14T07:33:52+00:00

I have a <ul> with each <li> having an id like <li id=’entry24′> .

  • 0

I have a <ul> with each <li> having an id like <li id='entry24'>. When one is clicked, I need to query the server for that entries information, by sending a get request to /query/getEntry/id=24.

Using this code:

for(var entry = 0; entry < entryIds.length; entry++) {
    $("#entry" + entryIds[entry]).click(function() {
        $.get(
            "/query/getEntry",
            {id: entryIds[entry]},
            getEntryCallback,
            "html"
        )
    });
}

I found that every request was sending the same id – the id of the last entry. After some research, I modified my code to this:

for(var entry = 0; entry < entryIds.length; entry++) {
    var entryId = entryIds[entry];
    $("#entry" + entryId).click(function(event) {
        $.get(
            "/query/getEntry",
            {id: event.target.id.replace("entry", "")},
            getEntryCallback,
            "html"
        )
    });
}

which works better (each <li> sends the correct id). However, looking at the Firebug console I can see requests being made with each click, but about 75% of the time they show /query/getEntry/id= in red.. meaning the id wasn’t actually sent and I didn’t get the results I was expecting.

I can confirm that every <li> DOES have an appropriate id field.

Any help/advice MUCH appreciated!

  • 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-14T07:33:54+00:00Added an answer on June 14, 2026 at 7:33 am

    Try this,

    $('ul li').click(function(){
        entryid = $(this).attr('title');
        $.get(
            "/query/getEntry",
            {id: entryid.replace("entry", "")},
            getEntryCallback,
            "html"
        )
    });
    

    For your html, define the entry id in a title attribute for all <li>s in your <ul>

    This should work if am not wrong since the AJAX function is called only when an <li> is clicked and the title attribute is unique to each <li> resulting in a unique id each time.

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

Sidebar

Related Questions

I have a rails app, where Im having a drop box like feature-set. Each
I'm working on a SaaS project that will have each customer having an instance
I have multiple applications each having a GUI from a different technology. I need
I have one UL having 3 Li, There are divs under each LI which
I have a collection of recipes, each having a number of ingredients. This information
I have two classes, one and two , each having a friend member function
I have three arrays each having SimpleXML Objects in them. They are structured like
I have a list of items which each list having a checkbox like this:
I want to have a list view with each row having two buttons like
I have two tables table1 and table2 each having a column named email along

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.