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

  • Home
  • SEARCH
  • 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 6970785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:45:15+00:00 2026-05-27T16:45:15+00:00

Is it possible to run a MySQL query using jQuery? I’m trying to emulate

  • 0

Is it possible to run a MySQL query using jQuery? I’m trying to emulate the functionality of voting on SE sites.

The vote counter on SE automatically updates without the need to reload the page (which is what I currently have, a hidden form that re-submits to the current page but runs a small block on PHP that updates the score of a question in the database). I’m assuming that is being done using Javascript/jQuery seeing as it is dynamic.

How can I do this? Is there a library which makes it easy and simple (like PHP)?

  • 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-27T16:45:16+00:00Added an answer on May 27, 2026 at 4:45 pm

    You can use ajax to call a server page (PHP / ASP /ASP.NET/JSP ) and in that server page you can execute a query.

    http://api.jquery.com/jQuery.ajax/

    HTML

    <input type='button' id='btnVote' value='Vote' />
    

    Javascript

    This code will be excuted when user clicks on the button with the id “btnVote”. The below script is making use of the “ajax” function written in the jquery library.It will send a request to the page mentioned as the value of “url” property (ajaxserverpage.aspx). In this example, i am sending a querystring value 5 for the key called “answer”.

     $("#btnVote").click(function(){     
        $.ajax({
                url: "ajaxserverpage.aspx?answer=5",
                success: function(data){
                    alert(data)
                 }
              });
    
      });
    

    and in your aspx page, you can read the querystring (in this example, answer=5) and
    build a query and execute it againist a database. You can return data back by writing a Response.Write (in asp & asp.net )/ echo in PHP. Whatever you are returning will be coming back to the variable data. If your query execution was successful, you may return a message like “Vote captured” or whatever appropriate for your application. If there was an error caught in your try-catch block, Return a message for that.

    Make sure you properly sanitize the input before building your query. I usually group my functionalities and put those into a single file. Ex : MY Ajax page which handles user related stuff will have methods for ValidateUser, RegisterUser etc…

    EDIT : As per your comment,

    jQuery support post also. Here is the format

     $.post(url, function(data) {
            alert("Do whatever you want if the call completed successfully")
     );
    

    which is equivalent to

     $.ajax({
            type: 'POST',
            url: url,           
            success: function(data)
                      {
                        alert("Do whatever you want if the call completed successfully")
                      }           
           });
    

    This should be a good reading : http://en.wikipedia.org/wiki/Same_origin_policy

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

Sidebar

Related Questions

Using only MySQL , I'm seeing if it's possible run an insert statement ONLY
I am trying to pull data using an mysql query that requires that I
I am using php mysql. First on form submission I run query on mysql
I am trying to calculate the time it takes a query to run using
i am using php with pdo , when i run a mysql query, is
Possible Duplicate: PHP MySQL multiple search query using option / select HTML form tags
I wonder if is it possible to run mysql command which can select an
Is it possible to run an UPDATE command on mysql 5.0 with a sub
I've trying to optimize a query on MySQL that takes around 15-20 seconds to
I need to run a MySQL query where the order is determined by an

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.