Note that there are some explanatory texts on larger screens.

plurals
  1. PO$.each() Callback is undefined (jQuery)
    text
    copied!<p>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.</p> <p>I thought I would give the very handy <code>.each()</code> function a try to put all the accepted and rejected ads into their own arrays, and then have PHP process each of them accordingly.</p> <p>However, on submitting the form, I get a <code>Callback is undefined</code> error from the FireBug console.</p> <p>Sample HTML (output by PHP):</p> <pre><code>&lt;li&gt;&lt;input type="radio" name="' . $a['adID'] . '" id="accept" value="' . $a['adID'] . '" /&gt; Approve&lt;/li&gt; &lt;li&gt;&lt;input type="radio" name="' . $a['adID'] . '" id="reject" value="' . $a['adID'] . '" /&gt; Reject&lt;/li&gt; </code></pre> <p><li></p> <p>... and this is the jQuery code:</p> <pre><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."); } }); }); }); </code></pre> <p><code>acceptedAds</code> / <code>rejectedAds</code> in the data parameter would be the variables that I want PHP to identify the arrays by when it looks for them.</p> <p>Syntax error, or is it a problem with how I'm passing the data through the AJAX function?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload