非同期通信でformタグの中にactionを指定すべきでしょうか?
<select id="mainDD" data-placeholder="Choose" class="chzn-select" style="width:600px;"> {% for i in json_data.items.values %} <option>{{ i }}</option> {% endfor %} </select> {% for key, values in preprocessed %} <select name="type" id=key> {% for counter, value in values %} <option value="{{ counter }}">{{ value }}</option> {% endfor %} </select> {% endfor %} <script type="text/javascript"> $(document).ready(function () { $('#mainDD').on('change', function() { console.log(11111111); console.log($(this).val()); console.log(22222222); console.log($('#mainDD :selected').text()) ; var thisType = "type" + $(this).val(); console.log(33333333); console.log(thisType); for(i=1; i<5; i++) { var thisId = "type" + i; console.log(444444444); console.log(thisId); console.log(555555555); console.log(thisType); if(thisType !== thisId) { $("#"+thisId).hide(); } else { $("#"+thisId).show(); } } }).trigger('change'); }); $('[name=type]').change(function() { var array = []; $('[name=alphabet] option:selected').each(function() { array.push($(this).text()); }); console.log(array); }); </script> <form id="postform" action="http://localhost:8000/app/" method="POST"> <input type="submit" value="送信"> </form> <script type="text/javascript"> $('[name=type]').change(function() { var array = []; $('[name=alphabet] option:selected').each(function() { array.push($(this).text()); }); console.log(array); }); </script>
とindex.htmlに書きました。
この arrayで取得した内容を送信ボタンが押された時に非同期通信で送信したいです。
今、actionで"http://localhost:8000/app/"(このhtmlが呼ばれるurl) とurlを指定していますがformタグの中にactionを指定すべきなのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/09/26 09:24
2017/09/26 09:42
退会済みユーザー
2017/09/26 09:59
2017/09/26 11:02