title: Why cant I POST into sqlite from AJAX?
body: <p>Im trying to incorporate a local save feature into my Web App and every time I send data in any form I get the following error:</p>
  
  <p>builtins.TypeError and then a stack trace in /SaveFile and jquery-3.1.1.js:9536 POST <a href="http://127.0.0.1:5000/SaveFile" rel="nofollow noreferrer">http://127.0.0.1:5000/SaveFile</a> 500 (INTERNAL SERVER ERROR) in the console log when I run the app</p>
  
  <p>I set up everthing in flask below as follows:</p>
  
  <pre><code>from flask import Flask, render_template, request
  import sqlite3
  import requests
  from requests import Request
  import json
  
  DATABASE = 'data/data.db'
  
  app = Flask(__name__)
  
  db = sqlite3.connect(DATABASE)
  cur = db.cursor()
  
  cur.execute("CREATE TABLE IF NOT EXISTS myrecipes(id INTEGER PRIMARY KEY,     name TEXT, rating TEXT, author TEXT, source TEXT)")
  </code></pre>
  
  <p>db.commit()</p>
  
  <pre><code>@app.route('/')
  def index():
      return render_template("index.html")
  
  @app.route('/SaveFile', methods=['POST', 'GET'])
  def SaveFile(data):
      if request.method == 'POST':
          cur.execute('INSERT INTO myrecipes(name) VALUES(?)', json.stringify(data))
          db.commit()
      return render_template('SaveFile.html')
  if __name__ == "__main__":
      app.debug = True
      app.run()
  
  #j=requests.get(url)
  </code></pre>
  
  <p>AJAX function:</p>
  
  <pre><code> function saveRecipe(title){
  
      $.ajax({
              type : "POST",
              url : "/SaveFile",
              data: { 'name': this.title },
              success: function(data) {
                  console.log("correct");
              },
         error: function(err) { alert(err); }
          });
  
  }// Save end
  </code></pre>
  
  <p>Im sorry that I cant include more info in the post but im not even sure where im going wrong or what im missing, I added the table as I left that out of the code by mistake.</p>