python flask jquery获取问题


                    

此Web服务器问题的神秘之处是什么。 </ p>

这是我的代码,它在本地服务器上运行良好,但是在Web服务器上却不起作用:</ p>

  $。ajax({
       网址:“ / flask / templates / table.html”,
       类型:“ get”,
       数据:{jsdata:$(“ #select option:selected”).text()},
       成功:功能(响应){
         $(“#place_for_suggestions”)。html(response);

       },
       错误:function(xhr){
         //处理错误
       }
     });
</ code> </ pre>

烧瓶侧面:</ p>

  @ FlaskApp2.route('/ flask / templates / table.html',methods = ['GET','POST'])
def table():

     modid = request.args.get('jsdata')

     打印“ Hello !!!!!!!!!!!!!!!!!!!”,modid
     返回render_template('table.html')
</ code> </ pre>

我尝试查看@ FlaskApp2.route中的任何活动,但我只看到无声!</ p>

此代码有什么问题? </ p>
     </ div>

展开原文

原文

What is the mystery of this Web Server issue.

Here is my code its work well on local server, but in the Web Server it's doesn't work:

$.ajax({
      url: "/flask/templates/table.html",
      type: "get",
      data: {jsdata: $( "#select option:selected" ).text()},
      success: function(response) {
        $("#place_for_suggestions").html(response);

      },
      error: function(xhr) {
        // handle error
      }
    });

The flask side:

@FlaskApp2.route('/flask/templates/table.html', methods=['GET', 'POST'])
def table():

    modid = request.args.get('jsdata')

    print "Hello!!!!!!!!!!!!!!!!", modid 
    return render_template('table.html')

I try to see any activity in @FlaskApp2.route but I see only silent !

What is wrong with this code?

1个回答


与路线匹配时,methods = ['GET','POST']的动词区分大小写。 因此,在您的.ajax中,请使用 method:'GET'</ code>而不是 type:'get'</ code>。 在更高版本的jquery中, type </ code>已由 method </ code>代替。</ p>
     </ div>

展开原文

原文

The verbs of the methods=['GET','POST'] are case sensitive when matching your route. So in your .ajax use method: 'GET' instead of type: 'get'. On later versions of jquery type has been replaced by method.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐