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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:31:17+00:00 2026-05-27T15:31:17+00:00

I have this: $(#upvote).click(function(){ var up = parseInt(document.getElementById(‘voteScore’).innerHTML); up++; document.getElementById(‘voteScore’).innerHTML = up; $.ajax({ type:

  • 0

I have this:

$("#upvote").click(function(){
    var up = parseInt(document.getElementById('voteScore').innerHTML);
    up++;
    document.getElementById('voteScore').innerHTML = up;
    $.ajax({
            type: 'POST',
        url: 'include/mysql_lib.php',
        data: {'data[]':['upvote','<?php echo $id; ?>', '<?php echo $uid; ?>']},
        dataType: "text",
        success: function(dataType) {
                if (dataType == "false") {
                    var up = parseInt(document.getElementById('voteScore').innerHTML);
                    up--;
                    document.getElementById('voteScore').innerHTML = up;
                }
        }
    });
});

The mysql_lib.php file (if an error is found) has a line like this:

return "false";

What am I doing wrong? I’ve never used jQuery before.

  • 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-27T15:31:17+00:00Added an answer on May 27, 2026 at 3:31 pm

    The AJAX function’s server response (the ‘dataType’ variable in your code) stores whatever your PHP script wrote-out to the server. In your PHP script if you return "false" that will return a string from a function, but if you want to pickup the value in your JavaScript you should use echo "false" so that the JavaScript’s response from the server will be false.

    function test() {
        //do some work
        return "false";
    }
    echo test();//this will output "false" to the browser
    
    function test() {
        echo "false";//this will output "false" to the browser
    }
    

    When running into issues like this it is a good idea to put a console.log(dataType) or alert(dataType) inside your AJAX callback function to see what is being output by your PHP. The response from your PHP script can also be viewed in most developer tools (like FireBug).

    And a suggestion for ya. If you want to get into outputting more complex information from your PHP script, take a look at the PHP json_encode() function which makes communicating between PHP and JavaScript painless.

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

Sidebar

Related Questions

Currently, I have: $(#upvote).click(function(){ var up = parseInt(document.getElementById('voteScore').innerHTML); up++; document.getElementById('voteScore').innerHTML = up; $.ajax(include/mysql_lib.php?op=upvote&v1=<?php echo
I have this code: $(document).ready(function() { $(.vote, .vote1).click(function() { var id = $(this).attr(id); var
I have this function: $(function() { $('.upvote').click(function() { voteActions(upvoteID, this.id); } ); $('.downvote').click(function() {
jQuery: $(.upvote).click(function() { var id = $(this).attr('id'); var changeImage = ($(this).children('img').attr('src') === siteUrl +
I have the following AJAX function to update votes clicked. $(function() { $(.vote).click(function() {
I think I got the jQuery imports sorted like this: <script type=text/javascript src=https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js></script> <script
i have this jquery code with an ajax request that works fine, but the
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

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.