ajax测试wepApi模板
<body> <%--<input id="CreditValueInput" />--%> <button id="SubmitButton">点击跳转</button> <form id="form1" runat="server"> <div> <script src="/Scripts/jquery-1.10.2.min.js"></script> <script src="/Scripts/Common/common.js"></script> <script src="/Scripts/jquery.lazyload.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#SubmitButton").click(function () { //var CreditValue = $("#CreditValueInput").val(); alert("ajax准备开始"); //return; var myDate = new Date();//获取系统当前时间 $.ajax({ //门店储值卡,测试的api接口 url: "http://api.baidu.com/api/StoredCard/StoredCardApiTest3", type: "Post", data: { Name: "a", Content: "描述了一个算法啊啊啊", NumberOne: '1', NumberTwo: "9", CreateDate: "12:35:44" }, success: function (obj) { if (obj.code == "1") { alert("成功");//成功之后跳转到显示充值成功的页面 alert("Msg:" + obj.Msg + "Status:" + obj.Status); return; } if (obj.code == "0") { alert("服务器返回来一个失败,请检查语句。" + obj.msg); alert("Msg:" + obj.Msg + "Status:" + obj.Status); return; } return; }, error: function () { alert("失败"); } }) alert("ajax完成"); }) }) </script> </div> </form> </body>