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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:28:05+00:00 2026-06-14T18:28:05+00:00

I’ve got a table and fields with onclick option: <td class=name onclick=ajax_update_entries(‘<?php echo $field[‘Player’][‘name’];

  • 0

I’ve got a table and fields with “onclick” option:

<td class="name" onclick="ajax_update_entries('<?php echo $field['Player']['name']; ?>')">

It calls function:

function ajax_update_entries(player_name)
  {
  $.post('http://mysite.com/entries/get_entries/' + player_name, function(data)
    {
    $('#gameText').html(data);
    });
  setTimeout('ajax_update_entries(player_name)', 30000);
  }

What it does very good is going to requested page after click on the table field. What it does very wrong, it doesn’t recognize “player_name” parameter in setTimeout which should refresh it. In the Opera console it returns:

Uncaught exception: ReferenceError: Undefined variable: player_name

and IE says there’s no definition of ‘player_name’.

But on the other hand, if I go with:

setTimeout('ajax_update_entries("Michael Jordan")', 30000);

it works and will refresh the page with parameter: Michael Jordan.

So my question is: what’s wrong with this script? I mean, why is the variable player_name suddenly forgotten? How to fix it?

  • 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-14T18:28:06+00:00Added an answer on June 14, 2026 at 6:28 pm

    You need this instead:

    setTimeout(function() {
        ajax_update_entries(player_name);
    }, 30000);
    

    The variable was not forgotten, the problem is that you were passing the function call as a string to setTimeout. What happens then, is that it goes through eval (which is not good, by the way), without its original context, so the javascript interpreter does not know what to pass. Hence the error.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
i got an object with contents of html markup in it, for example: string

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.