Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在使用Ajax将数据发布到Flask时使用Python NoneTypeDataType_Jquery_Python_Ajax_Flask - Fatal编程技术网

Jquery 在使用Ajax将数据发布到Flask时使用Python NoneTypeDataType

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数据发布到我的flask控制器,

  • 如果没有ajax,它只需查找:
这是我的html模板中的表单:

<form  method=post action="{{ url_for( 'editreals', id=realist.index(row), name='head') }}">

  • 使用ajax,我使用jquery插件()就地编辑:

    <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>
    
    从web调试器发送的数据对我来说似乎正常:

    FormData :
      rubric: datasubmitted
      id: 0
    
    那些字段只是字符串,不是吗?为什么python说它们是非类型数据类型

    [编辑-1]

    标题:

    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
    ,作为
    POST
    的一部分-Flask在
    请求下公开此数据。表单
    。将
    i=int(request.args.get(“id”)
    更改为
    i=int(request.form.get(“id”))
    ,一切都会正常工作。

    在您使用的工作代码中
    ind
    (这是您在视图中查找的内容),但通过ajax发送的数据正在发送
    id
    。。。它不应该是
    ind
    ?是的,我编辑视图是为了请求id,而不是ind,sry我忘记在我的问题中指定它。你能提供完整的堆栈跟踪吗?你好,你需要更多信息吗?很有效,非常感谢,我不清楚这两种发布数据的方法。
    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'