Perform Node.JS Query based on HTML select option
<p>I am attempting to perform specific queries to a mySQL database based on what a user selects from my website's select options.</p>

<p>HTML:</p>

<pre><code>&lt;select id = "year"&gt;
&lt;option value = "yr" selected&gt;Choose a Year&lt;/option&gt;
&lt;option id = "2015"&gt;2015&lt;/option&gt;
&lt;option value="2014"&gt;2014&lt;/option&gt;
&lt;option value="2013"&gt;2013&lt;/option&gt;
&lt;option value="2012"&gt;2012&lt;/option&gt;
&lt;option value="2011"&gt;2011&lt;/option&gt;
&lt;option value="2010"&gt;2010&lt;/option&gt;
&lt;option value="2009"&gt;2009&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>Node.JS:</p>

<pre><code>    function handleDatabase(request,response){
     pool.getConnection(function(err, connection){
    //Check if there's an error, if so, stop connection and print error
      if(err){
        connection.release();
        response.json({"code": 50, "status": "Error in connection to database"});
        return;
    }
    connection.query("select * from 'fifteen' where TYPE = 'Mischief'", function(err, rows){
      connection.release();
      if(!err){
        response.json(rows);
      }
    });
      response.json({"code": 50, "status" : "Error in connection to database"});
      return;
    });
  });
}

app.get('/',function(request,response){
    handleDatabase(response,request);
    }
</code></pre>

<p>AJAX:</p>

<pre><code>$(document).ready(function(){
    $('#year').click(function() {
            $.ajax({
                type: 'GET',
                url: 'http://localhost:8888/',
                dataType: 'json',
                success: function () {
                    console.log("Success");
                },
                error: function (data) {
                    console.log("Error.", data);
                }

            });
    });
});
</code></pre>

<p>I would like the user to be able to select which ever year they want, and then perform an AJAX request onto the server which would then perform a query onto the database. For example, the user selects 2014, make an AJAX request to the server, the server then performs a query onto the table, fourteen, and returns all data from it.</p>