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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:39:09+00:00 2026-06-05T16:39:09+00:00

My JQuery code is posting, because the success function is firing. The problem is

  • 0

My JQuery code is posting, because the success function is firing. The problem is that the PHP $_POST request is not receiving the data. For debugging purposes, I tried to use alert(data) to display what I hoped would be an array and show me if there was a way to parse whatever was being passed. Instead, the alert box just shows “[object Object].” I need to get this data into a form I can use in PHP for the callback function.

Here’s the JQuery:

$(document).ready(function(){
//JQuery for the submission of a new list item.
    $('input.[class$="-arrow"]').click(function(e){
        e.preventDefault(); //put e in function.
        var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';

        if ($(this).hasClass('up-arrow')) {
            var arrowdirection = 'up';
            var entry = $(this).val();
        }
        else if ($(this).hasClass('down-arrow')) {
            var arrowdirection = 'down';
            var entry = $(this).val();
        }

        var data = {
            action: 'cb_lud_arrow_action',
            arrow: arrowdirection,
            entryID: entry
        };

        $.ajax ({
            type: 'POST',
            url: ajaxurl,
            data: data,
            datatype: "text",
            success: function(){
                alert(data);
                alert('Thanks for the vote!'); //for debug. Alert is showing! Still not submitting data to database though.
                $('.line-items-rows').fadeOut('fast').delay(1000).fadeIn('fast');
            }
        });
});
});

And here’s the callback PHP function (which is not updating the database as it should):

function cb_lud_arrow_callback(){       
    //Redefine basic variables
    global $wpdb;
    $cb_lud_prefix = $wpdb->prefix;
    $cb_lud_table = $cb_lud_prefix . 'cb_list_up_down';
//find the values posted to the form
    $cb_lud_arrow_keys = array_keys($_POST['arrow']);
    $cb_lud_arrow_values = array_values($_POST['entryID']);
    $cb_lud_entry_id = (int)$cb_lud_arrow_values[2];


        //set some variables to "up" or "down" depending on form input.
            if (strpos($cb_lud_arrow_keys[2], 'up-ID') > 0) {
                $cb_lud_arrow_direction = "up";
            }
            else if (strpos($cb_lud_arrow_keys[2], 'down-ID') > 0) {
                $cb_lud_arrow_direction = "down";
            }
            else {
                $cb_lud_arrow_direction = "nothing";
            }

        //Create the update query that will record the up and down votes.
            //Up votes
            if ($cb_lud_arrow_direction == "up" && $cb_lud_arrow_direction != "nothing") {
                $wpdb->query('UPDATE '.$cb_lud_table.' SET up_votes=up_votes+1
                    WHERE entry_ID='.$cb_lud_entry_id.'');
            }
            //Down votes
            else if ($cb_lud_arrow_direction == "down" && $cb_lud_arrow_direction != "nothing") {
                $wpdb->query('UPDATE '.$cb_lud_table.' SET down_votes=down_votes+1
                    WHERE entry_ID='.$cb_lud_entry_id.'');
            }   

die(); // this is required to return a proper result
} 
  • 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-05T16:39:10+00:00Added an answer on June 5, 2026 at 4:39 pm

    Use Firefox and install Firebug. Then go to the Firebug console and execute the jQuery event. It will show you all the AJAX transactions, what was sent, headers, post, etc, and what was received.

    Also, you can really shorten your AJAX call to this:

    $.post(ajaxurl, data, function(data){
      $('.line-items-rows').fadeOut('fast').delay(1000).fadeIn('fast');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm posting simple version of php and Jquery code of the page that I
jQuery Code: $(document).ready(function(){ $.getJSON('dat.js', function(data) { var obj = JSON.parse(data); alert(obj[0].title); }); }); My
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
my jquery code not run with IE6 but runs all others including IE7. It
My jQuery code: $(document).ready(function() { chrome.extension.sendRequest({get: height}, function(response) { height = response.value; }); $(#id).css(height,
I have some jquery code that is doing an ajax lookup and returning comma
I have some jQuery code that highlights a link when clicked, and changes the
I have a simple jQuery code that runs on a web page that has
I'm writing a php script that takes some c code and tests it against
the code below is a jquery POST request javascript. i want to use the

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.