我想發送我所有的表單元素的名稱,值和標籤,當我點擊一個按鈕時,我沒有提交提交按鈕,因爲我得到了他們在一個錯誤的順序,所以我使這個在JavaScript:每個Ajax發送一個數組到一個python-server-script
$('#mybutton').click(function() {
m.modal('show');
var all=[];
$('textarea, select, input').each(function(index){
var label= $(this).parent().find('label').html();
var value= $(this).val();
var name= $(this).attr('name');
all.push([name,value,label]);
})
$.ajax({
dataType: "text",
url: "befund",
data: {
wert : all
},
success: function(data){
$('#mymodal').find('.modal-body').html(data);
}
})
});
在Python服務器腳本(瓶)我試試這個
:
@app.route('/web/befund')
def modalcontent() -> str:
x = request.query.wert[0][1]
print (x)
return('test')
的問題是,我在瀏覽器中看到,發送正確的數組,但是當我嘗試用「request.query.wert [0] [1]」查看數組的一個元素時「我只得到一個http錯誤500(internerl se rver錯誤)。有人可以幫我嗎?
這既沒有工作:(Mayby我都用這個的POST方法 –
看看這個主題 –
http://stackoverflow.com /問題/ 464040 /如何,都-後和獲取變量,處理功能於蟒蛇 –