title: Jquery Flask capturing checkbox value
body: <p>I am trying to capture the data from checkbox by assigning value in jquery and passing it to backend each time search is run by the user. It is not working for me, tried several ways.</p>
  
  <p>Use case: As a user I would like to search and be able to check for various search options.</p>
  
  <p><strong>template:</strong></p>
  
  <pre><code>$('a#process_input').bind('click', function () {
      $.getJSON('/background_process', {
      checkbox1: $('input[name="checkbox1"]').val(),
      input_search: $('input[name="input_search"]').val(),
      },
  
      function (data) {
          ul.empty();
          $.each(data.result, function (index, element) {
  
          ...
          ... &lt;some irrelevant code...&gt;
  
          &lt;input type=text size=40 name=input_search&gt;
          &lt;a href=# id=process_input&gt;
              &lt;button class='btn btn-default'&gt;Submit&lt;/button&gt;
          &lt;/a&gt;
      &lt;/form&gt;
      &lt;form method="POST" action="/"&gt;
          &lt;p&gt;Please select allergy options below:&lt;/p&gt;
          &lt;input type="checkbox"  name="checkbox1"/&gt;Allergy 1
  </code></pre>
  
  <p><strong>backend</strong></p>
  
  <pre><code>@app.route('/background_process', methods=['GET', 'POST'])
  
  def background_process():
      try:
          checkbox1 = request.args.get("something")
  
          search_word = request.args.get('input_search', 0, type=str)
  
          if search_word:
  
              return jsonify(result=yummly_search(search_word, checkbox1))
          else:
              return jsonify(result='Try again.')
  except Exception as e:
          return str(e)
  </code></pre>