Feb-22-2020, 09:26 PM
I have a file (runwsgi.py) that starts the server with the intention of getting a variable from a form using an ajax. The problem that prints the value none? See the wsgi code below, because I can't find an error:
Ajax section :
Note: Debugging in the chrome browser I see in the Form Data section it is possible to view the variable with the input value (ws_search_field: text)
Would there be an error to get the variable value in the code below?
Ajax section :
$('.btn').text('search').click(function() {
// atribui valor a variavel
var ws_search_field = $('.ws-search-field').val();
// set method ajax:
$.ajax({
type : 'POST',
url : 'runwsgi.py',
data : { ws_search_field : ws_search_field },
dataType : 'json',Wsgi section :import cgi
def apps(environ, ws_output):
ws_mtd = environ['REQUEST_METHOD']
ws_form = cgi.FieldStorage()
ws_input = ws_form.getvalue('ws_search_field')
if ws_mtd == 'POST':
status = '200 OK'
headers = [('Content-type', 'text/html; charset=utf-8')]
ws_output(status, headers)
return [str(ws_input).encode('utf-8')]The output I get from the ws_search_field variable is: NoneNote: Debugging in the chrome browser I see in the Form Data section it is possible to view the variable with the input value (ws_search_field: text)
Would there be an error to get the variable value in the code below?
ws_form = cgi.FieldStorage()
ws_input = ws_form.getvalue('ws_search_field')
