I wrote a post before processing the request, met today get some different processing parameters
post requested address:
https://www.cnblogs.com/whycai/p/10914349.html
get results:
Not the same place:
A, js change in get, data processing is not the same
Second, the front end of the rear end to get the same value does not pass
form.get into args.get
methods into GET
Complete the following:
1.html (unchanged)
1 <html> 2 <head></head> 3 <body> 4 <form class="formXXX1" > 5 <br class="formXXX2" /> 6 <div class="form-group"> 7 <label for=" 8 telephone14">手机号: <input class="form1" type="iphone" id="a" name="a" maxlength="11" placeholder="请输入11位合法手机号" /> </label> 9 </div> 10 <div class="example-box"> 11 <label> 环境:</label> 12 <label class="radio"> <input type="radio" id="b" name="b" value="0" checked="" /><span>b1</span> </label> 13 <label class="radio"> <input type="radio" id="b" name="b" value="1" /><span>b2</span> </label> 14 </div> 15 <br /> 16 <div class="form-group"> 17 <button class="btn btn-primary" type="button" id="notify">提交</button> 18 </div> 19 </form> 20 </body> 21 </html>
2.js
. 1 // JS file filled in accordance with the actual path 2 <Script type = "text / JavaScript" the src = "static / JS / jquery.min.js"> </ Script> . 3 . 4 <Script type = "text / JavaScript"> . 5 $ ( '# Notify') ON ( 'the Click'. , . 6 function () { . 7 // take variable . 8 var B = $ (. "INPUT [name = 'B']: the checked") Val (); // single-box values . 9 var A = $ ( '# A' ) .val (); 10 . 11 12 is // less than 11 Tip 13 is IF (a.length =. 11! ) { 14 Alert ( 'phone number is less than 11 ,please enter again'); 15 return; 16 } 17 18 //ajax 提交数据 19 20 $.ajax({ 21 type: "GET", 22 dataType: "json", 23 url: "/aaa",//后端请求 24 data: {a:a,b:b}, 25 success: function(result) { 26 console.log(result); 27 { 28 alert('3333' + result); 29 } 30 }, 31 error: function (result) { 32 console.log(result); 33 { 34 alert(result); 35 } 36 } 37 }); 38 39 }) 40 41 </script>
python:
. 1 @ app.route ( ' / AAA ' , Methods = [ ' the GET ' ]) 2 DEF AAA (): . 3 A = request.args.get ( ' A ' ) . 4 B = request.args.get ( ' B ' ) . 5 Print (A, B) . 6 # MSG = bbb (A, B) # bbb method call to get the return value . 7 MSG = A, B . 8 return jsonify (MSG)