[Flask] Possibly OT: result of form submission with Ajax is page's own sourcecode

Alex Hall ahall at autodist.com
Mon Apr 25 12:16:11 EDT 2016


Hello all,
I'm sorry if this is off topic. I've never seen this before, and I'm pretty
new to web development. Hopefully it turns out to be something Flask is
doing.

I have a page made from templates and hosted by Flask. The page includes a
form, with a couple JQuery datepickers, input fields, hidden fields,
dropdown, and a checkbox. My JS normally posts the form to itself, which my
view function handles. That view function returns the rendered template if
the form was sent via GET or failed validation, else it grabs the form
contents, queries a database, and sends back some JSON for JS to parse.

Today, as I was adding the datepickers and doing some other changes, my
form suddenly started displaying an error in the web console that it
couldn't parse the JSON. When I told it to print the JSON, I got back a
string that is simply the page's own source code, given back to it. Flask's
command line is showing no errors, and my view function is working
properly. Somehow, though, the form is being handed HTML code of the page
instead of JSON. The only error is when the JS tries to parse this, since
it can't. Other than that, I'm seeing no problems anywhere--no syntax
problems, nothing missing, nothing at all. I don't know why the result of
an Ajax call in JS would be my page's source code, or if that means
anything in particular. Hopefully I'm making sense, and am not too off
topic. Thanks in advance for any thoughts.

-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160425/1ddf95c4/attachment.html>


More information about the Flask mailing list