我想弄清楚如何将ajax数据发送到我的烧瓶控制器,如果没有ajax,只需查找:
这是我的html模板中的表单:
在我的视图.py,获取索引“id”并对其进行强制转换:
^{pr2}$
$(document).ready(function() {
$(".rubric").editable('{{ url_for('editskills') }}',{
submit: 'Ok',
cancel: 'Cancel',
tooltip : 'Clic to edit',
type : 'textarea',
name : 'rubric'
});
});
{{ row["rubric"] }}
作为回报,我得到500个错误
我不明白为什么控制器总是发回那个错误:TypeError: list indices must be integers, not NoneTypeDataType :
从web调试器中,我发送的数据似乎没问题:FormData :
rubric: datasubmitted
id: 0
那些字段只是字符串,不是吗?为什么python说它们是非类型数据类型?在
[编辑-1]
标题:Request URL:http://: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::5000
Origin:http://:5000
Referer:http://: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
预览:File "/home/noa/virtualenv/folio/foliodev/portfolio/views.py", line 39, in editskills
v = liste[i]
TypeError: list indices must be integers, not NoneType
抱歉,我犯了个错误,有导致错误的代码: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'
这让我把重点放在为什么我发送的数据是“非类型”上
非常感谢您抽出时间。在