Jquery 在使用Ajax将数据发布到Flask时使用Python NoneTypeDataType
我正试图找出如何将ajax数据发布到我的flask控制器,Jquery 在使用Ajax将数据发布到Flask时使用Python NoneTypeDataType,jquery,python,ajax,flask,Jquery,Python,Ajax,Flask,我正试图找出如何将ajax数据发布到我的flask控制器, 如果没有ajax,它只需查找: 这是我的html模板中的表单: <form method=post action="{{ url_for( 'editreals', id=realist.index(row), name='head') }}"> 使用ajax,我使用jquery插件()就地编辑: <script> $(document).ready(function() { $(".rubri
- 如果没有ajax,它只需查找:
<form method=post action="{{ url_for( 'editreals', id=realist.index(row), name='head') }}">
- 使用ajax,我使用jquery插件()就地编辑:
从web调试器发送的数据对我来说似乎正常:<script> $(document).ready(function() { $(".rubric").editable('{{ url_for('editskills') }}',{ submit: 'Ok', cancel: 'Cancel', tooltip : 'Clic to edit', type : 'textarea', name : 'rubric' }); }); </script> <h3 class="rubric", id={{ sklist.index(row) }}>{{ row["rubric"] }}</h3>
那些字段只是字符串,不是吗?为什么python说它们是非类型数据类型 [编辑-1] 标题:FormData : rubric: datasubmitted id: 0
对不起,我弄错了,有导致错误的代码:Request URL:http://<Server-IPAddress>:5000/editskills Request Method:POST Status Code:500 INTERNAL SERVER ERROR Request Headersview source Accept:text/html, */*; q=0.01 Accept-Encoding:gzip,deflate,sdch Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 Connection:keep-alive Content-Length:25 Content-Type:application/x-www-form-urlencoded; charset=UTF-8 Cookie:session=eyJsb2dnZWRfaW4iOnRydWV9.BcMSfg.j5SaVklwzSzTdttCciYL_9dqZNg DNT:1 Host:<Server-IPAddress>:5000 Origin:http://<Server-IPAddress>:5000 Referer:http://<Server-IPAddress>:5000/competences User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36 X-Requested-With:XMLHttpRequest Form Dataview sourceview URL encoded rubric:1Réseaux id:0 Response Headersview source Connection:close Content-Type:text/html; charset=utf-8 Date:Thu, 23 Jan 2014 20:52:19 GMT Server:Werkzeug/0.9.4 Python/2.7.3 X-XSS-Protection:0
如果我改为试试这个:i = request.args.get("id", type=int) v = liste[i]
它直接打断演员:i = int(request.args.get("id"))
这让我关注为什么我发送的数据是“非类型的”i = int(request.args.get("id")) TypeError: int() argument must be a string or a number, not 'NoneType'
非常感谢您的时间。问题在于,在您的工作
示例中,您正在发送查询字符串中的表单中
(这使得id
request.args可以使用)。jEditable正在响应正文中发送
,作为id
的一部分-Flask在POST
。将请求下公开此数据。表单
更改为i=int(request.args.get(“id”)
,一切都会正常工作。在您使用的工作代码中i=int(request.form.get(“id”))
(这是您在视图中查找的内容),但通过ajax发送的数据正在发送ind
。。。它不应该是id
?是的,我编辑视图是为了请求id,而不是ind,sry我忘记在我的问题中指定它。你能提供完整的堆栈跟踪吗?你好,你需要更多信息吗?很有效,非常感谢,我不清楚这两种发布数据的方法。ind
i = request.args.get("id", type=int) v = liste[i]
i = int(request.args.get("id"))
i = int(request.args.get("id")) TypeError: int() argument must be a string or a number, not 'NoneType'