postしたデータをjson形式で値を取得できないです。
index.htmlに
<html lang="en"> <head> <meta charset="UTF-8"> <title>入力ページ</title> </head> <body> <form method="post" action="response"> {% csrf_token %} <p>id:</p> <input id="id" name="id" type="text" placeholder="id" class="form-control"> <input type="submit" value="送信する"> </form> <script type="text/javascript"> $('form')submit(function(){ var data = $('form').serializeArray(); data = parseJson(data); console.log(data); } </script> </body> </html>
とコードを書いて実行しても
console.log(data);で何も値が取得されません。なぜこの書き方だとinputタグのidの値で入力したデータがjsonでconsole.log(data);で取得できないのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/10/31 06:30
2017/10/31 06:33
退会済みユーザー
2017/10/31 06:46
退会済みユーザー
2017/10/31 06:46
2017/10/31 06:50
退会済みユーザー
2017/10/31 07:09
2017/10/31 07:36
退会済みユーザー
2017/10/31 07:42
2017/10/31 07:48
2017/10/31 07:50 編集
退会済みユーザー
2017/10/31 07:57