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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:37:46+00:00 2026-06-08T05:37:46+00:00

I’m trying to build a very simple Admin area where the administrator can approve

  • 0

I’m trying to build a very simple Admin area where the administrator can approve or reject image / link ads before they’re shown on the site. They will use radio buttons that contain an “accepted” or “rejected” ID, and the value is the unique ID number for the ad.

I thought I would give the very handy .each() function a try to put all the accepted and rejected ads into their own arrays, and then have PHP process each of them accordingly.

However, on submitting the form, I get a Callback is undefined error from the FireBug console.

Sample HTML (output by PHP):

<li><input type="radio" name="' . $a['adID'] . '" id="accept" value="' . $a['adID'] . '" /> Approve</li>
<li><input type="radio" name="' . $a['adID'] . '" id="reject" value="' . $a['adID'] . '" /> Reject</li>
  • … and this is the jQuery code:

    $(document).ready(function() {
    
            $("#save").click(function() {
                var arrayOfAccepted = new Array();
                var arrayOfRejected = new Array();
    
                $.each("input:radio[id='accept']:checked"), function() {
                    arrayOfAccepted.push($(this).val());
                }
    
                $.each("input:radio[id='reject']:checked"), function() {
                    arrayOfRejected.push($(this).val());
                }
    
                    $.ajax({
                    type: 'POST',
                    url: 'exe/fn.moderateAds.php',
                    data: {acceptedAds : arrayOfAccepted, rejectedAds : arrayOfRejected},
                    success: function() {
                    alert("Changes saved successfully.");
                    }
                    });
                });
            });
    

    acceptedAds / rejectedAds in the data parameter would be the variables that I want PHP to identify the arrays by when it looks for them.

    Syntax error, or is it a problem with how I’m passing the data through the AJAX function?

    • 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-08T05:37:47+00:00Added an answer on June 8, 2026 at 5:37 am

      Your closing parenthesis is in the wrong place and you’re not selecting elements, but rather iterating a string. Also, your selector is a little too specific.

      $.each("input:radio[id='accept']:checked"), function() {
          arrayOfAccepted.push($(this).val());
      }
      

      should be:

      $("input:radio[id='accept']:checked").each(function() {
          arrayOfAccepted.push($(this).val());
      });
      

      And the same for the other one. Right now, it’s being treated as one comma operator with a left-hand operand of $.each("input:radio[id='accept']:checked") (hence the error you see) and a right-hand operand of an anonymous function that is never used.

      Code tip: use [] instead of new Array().

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

    Sidebar

    Related Questions

    link Im having trouble converting the html entites into html characters, (&# 8217;) i
    I am trying to understand how to use SyndicationItem to display feed which is
    Basically, what I'm trying to create is a page of div tags, each has
    I'm new to using the Perl treebuilder module for HTML parsing and can't figure
    I have just tried to save a simple *.rtf file with some websites and
    I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
    I am trying to render a haml file in a javascript response like so:
    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
    We're building an app, our first using Rails 3, and we're having to build

    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.