前端代码: 1 <input id="txtNum1" name="txtNum1" type="text" width="130" /> 2 <select id=&quo ...
前端代码:
1 <input id="txtNum1" name="txtNum1" type="text" width="130" /> 2 <select id="fh" name="fh"> 3 <option id="jia" value="+">+</option> 4 <option id="jian" value="-">-</option> 5 <option id="chen" value="*">*</option> 6 <option id="chu" value="/">/</option> 7 </select> 8 <input id="txtNum2" name="txtNum2" type="text" width="130" /> 9 <input id="btnSubmit" type="button" value="=" />10 <input id="txtResult" type="text" width="130" />11 12 @section scripts{13 <script>14 $(function () {15 $("#btnSubmit").bind("click", function () {16 debugger17 $.ajax({18 @*url: '@Url.Action("JS")',*@19 url: "/Home/JS",20 data: {21 "num1": $("#txtNum1").val(),22 "num2" : $("#txtNum2").val(),23 "fh":$("#fh").val()24 },25 dataType: "json",26 type: "post",27 success: function (data){28 $("#txtResult").val(data.Result);29 },30 error: function (e, a){31 alert(a);32 }33 })34 })35 })36 </script>37 }
原标题:使用ajax传递及接收数据
关键词:ajax
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。