title: Flask Python, trying to return list or dict to Ajax call
body: <p>Within a Flask app, I have the following ajax call:</p>
  
  <pre><code>    $.ajax({
              url: "{{ url_for( 'bookings.get_customer' ) }}",
              type: "POST",
              data: nameArray,
              success: function( resp ){
                  console.log( resp )
              }
          })
  </code></pre>
  
  <p>As you can see, I am passing an array against which I will search my mongo database, which will either return or not return a customer.</p>
  
  <p>So, the python def that is responsible for handling this ajax call is:</p>
  
  <pre><code>@bookings.route( '/get_customer', methods=[ 'POST' ] )
  def get_customer():
      name = {}
      for key, value in request.form.items():
       name[ key ] = value
  
      customer_obj = customer_class.Customer()
      results = customer_obj.search_customer( name )
  
      return results    
  </code></pre>
  
  <p>For argument's sake, lets say the customer_obj call returns the following list:</p>
  
  <pre><code>[{'customer': {
                 u'first_name': u'Dave', 
                 u'tel': u'0121212121458', 
                 u'country': u'UK',     
                 u'address2': u'Townington', 
                 u'address3': u'Cityville', 
                 u'email': u'dave@smith.com', 
                 u'postcode': u'A10 5BC', 
                 u'address1': u'10 High Street', 
                 u'second_name': u'Smith'
               }, 
   'customer_id': u'DaveSmithA10 5BCCat_Vegas1346244086'
  }]
  </code></pre>
  
  <p>When I try to return this to the ajax call as </p>
  
  <pre><code>return results
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code> TypeError: 'list' object is not callable
  </code></pre>
  
  <p>Here is the traceback:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1701, in __call__
  return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1689, in wsgi_app
  response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
  response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1361, in
  full_dispatch_request
  response = self.make_response(rv)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1450, in make_response
  rv = self.response_class.force_type(rv, request.environ)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 711, in
  force_type
  response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/test.py", line 818, in
  run_wsgi_app
  app_iter = app(environ, start_response)
  TypeError: 'list' object is not callable
  </code></pre>
  
  <p>Does anyone have any suggestions?</p>
  
  <p>Thanks</p>