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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:53:23+00:00 2026-05-29T12:53:23+00:00

Before anyone says try searching, I have – I realize this is probably a

  • 0

Before anyone says “try searching”, I have – I realize this is probably a simple solution, but I just can’t get it to work. This is my first venture into AJAX – and my knowledge of javascript is slightly above a 1st grader…I know I need to get up to speed on it.

I’m trying to build a nested task manager, using AJAX. I’m getting jammed up on the AJAX implementation…the list works well otherwise. The basic concept should output like this:

Goal: Create a nested task list

Milestone: Build the basic setup – completed 2/11/12

Task: Design the database – completed 2/11/12
Task: Design the php stuff – completed 2/11/12

Milestone: Add the finesse

Task: Include AJAX functioning
Task: Include CSS

As you click on the link, it runs my MySQL update to show the item being completed. I have three nested while loops (one for goals, one for milestones and one for tasks). They are near identical. Here’s the most deeply nested loop:

$query_tasks = mysql_query("SELECT * FROM task WHERE task_gid = '$task_gid' AND task_mid = '$task_mid' AND task_tid IS NOT NULL");
$t_numrows = mysql_num_rows($query_tasks);
if($t_numrows > 0){ 
    while( $get_task = mysql_fetch_array($query_tasks)){
    $task_id = $get_task['task_id'];
    $task_goal = $get_task['task_goal'];
    $task_due = $task_task['task_due'];
        $task_due = date("m/d/Y", $task_due);
    $task_complete = $get_task['task_complete'];
    $task_complete_date = $get_task['task_complete_date']; ?>

Here is my link to trigger the query:

    <a id="link" href="#"><?=$task_goal?> by <?=$task_due?> </a>
    }

Here is my ajax query:

<script type="text/javascript">
$('#link').click(function(){
$.ajax({
    type: "GET",
    url: "complete.php?id=<?=$task_id?>"
});
return false;
});
</script>

I’ve got it to work for one link (if I click on the last rendered link, it works as desired – but no other links do). I’ve tried calling the javascript in the head (my preferred method) as well as calling it each time the loop passes (not sure that’s a good idea, but whatever). My thought is to use the variable from the while loop for each task in the javascript function. I’ve tried placing the ajax script into a javascript function and calling it on the onClick behavior for the link, but no luck. Thoughts?

  • 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-29T12:53:27+00:00Added an answer on May 29, 2026 at 12:53 pm

    This is how you should do it:
    http://pastebin.com/ZMCzAS5H

    By setting a custom attribute (task_id) to your link you’ll be able to retrieve it later in the ajax request. This way you’ll use one event binder for all of the links instead of one for each link.

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

Sidebar

Related Questions

(Before anyone says anything Yes this was homework but i have already turned it
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
Before anyone recommends that I do a google search on this, I have. I
Has anyone seen this before - and can anything be done about it? This
I think I've asked this before but I can't find the question now, and
Has anyone run into this error message before when using a timer on an
Has anyone else run into this problem before? I've got a method that calls
Has anyone had this unusual(recurring) experience before? I'm trying to check out the project
Has anyone come across this issue before?
I was clicking elements just fine before, and this all worked, however now when

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.