About.schtml中的代码
@{ ViewData["Title"] = "About"; } <h2>@ViewData["Title"].</h2> <h3>@ViewData["Message"]</h3> <script src="/lib/jquery/dist/jquery.js"></script> @*<input type="button" value="开始监测!" onclick="location.href='@Url.Action("btnBeginListen_Click", "Home")'" />*@ <input type="button" id="btnBegin" name="btnBegin" value="开始监控!" /> <input type="text" disabled id="begin_state" value="" /> <br /> <input type="text" id="id_msg" name="id_msg" /> <input type="button" id="btnSub" name="btnSub" value="发送消息." /> <input type="text" disabled id="id_send_state" value="" /> @*<p>Use this area to provide additional information.</p>*@ <table border="1" width="960" height="50" align="center" style="text-align:center;font-size:15px;"> <tr> <td>序号</td> <td>名称</td> <td>服务器地址</td> <td>服务器端口</td> <td>发送的数据</td> <td>接收的数据</td> </tr> </table> <script type="text/javascript"> $(document).ready(function () { //发送消息 $("#btnSub").click(function () { var msg = $("#id_msg").val(); $.ajax({ type: "POST", url: "/Home/btnSend_Click", data: { "send_to": "127.0.0.1:42271", "msg_send": msg }, success: function (sesponseTest) { alert(sesponseTest); $("#id_send_state").val(sesponseTest); }, error: function (XMLHttpRequest, textStatus, errorThrown) { $("#id_send_state").val(errorThrown); alert("保存失败:" + errorThrown); } }); }); //开始监控 $("#btnBegin").click(function () { $.ajax({ type: "POST", url: "/Home/btnBeginListen_Click", success: function (sesponseTest) { alert(sesponseTest); $("#begin_state").val(sesponseTest); }, error: function (XMLHttpRequest, textStatus, errorThrown) { //$("#txt1").val(errorThrown); alert("保存失败:" + errorThrown); } }); }); }); </script>