利用javascript提交表单

时间:2022-05-11 18:33:23

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>乐运动数据同步</title>
<link href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
<style type="text/css">
html,body{width:100%;height:100%;margin:0;font:14px "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti;color:#ccc;background-color:#27ae60;}.logo{width:150px;height:64px;background:url(./images/spite_index) -29px -432px no-repeat;margin:80px auto 20px;}.header{color:#f4f4f4;margin-bottom:15px;font-size:21px;font-weight:200;text-align:center;}.header span{font-size:14px;}.form-group{margin-top:40px;margin-bottom:15px;}.form-group .text{width:450px;border:2px solid #27ae60;-webkit-box-shadow:none;box-shadow:none;font-size:16px;padding:13px 30px;border-radius:0;height:auto;text-align:center;margin:10px auto;}.form-group .text:focus{border-color:#208d4e;}a.submit{width:446px;background:#239650;border:1px solid #239650;-webkit-box-shadow:none;box-shadow:none;font-size:18px;color:#fff;padding:10px 30px;border-radius:0;height:auto;text-align:center;margin:0 auto;}a:hover{cursor:pointer;text-decoration:none;background:#208d4e;border-color:#208d4e;}.tip{width:375px;height:87px;background:url(./images/spite_index)-21px -513px;margin:80px auto 0;}
</style>
<script type="text/javascript">
$(function(){
$('#submit').on('click',function(){
var step=$('input[name=step]').val().replace(/(^\s*)|(\s*$)/g, "");

$.ajax({ //一个Ajax过程
type : "get",
url : 'http://appt.igeekery.com/wx-run/set-step.json?_lan=zh&_k=da3e20cc7e524a5a\
b22360372f564875&_v=36&_ch=16&_nw=wifi&_sdk=19&_product=fitmix&_terminal=2&uid=458009&uni\
onid=oIoQTsy2pk-LKb4hnq0EK9m_3QC4&openid=oBmGhuPxQVTPVBfZyWhskgT4TTos&step\
='
+step,
success : function(ret)
{

if(ret.code==0)
{alert("修改成功,请打开微信查看!");}
else
{alert("数据有误,请重新提交!");}

},
error : function(error)
{
alert("数据提交失败!");}

});



}
)
});

</script>
</head>
<body>
<div class="container">
<div class="logo"></div>
<p class="header">陆嵩小主,请输入您要设置的微信运动步数<br/>
<div class="form-group">
<form id="form" method="POST" action="http://pl.api.ledongli.cn/xq/io.ashx">
<input type="text" class="form-control text" name="step" value="" placeholder="输入步数(要比原来大)" />
<a id="submit" class="form-control submit">提交</a>
</form>
</div>

</p>
<div class="tip"></div>
</div>
</body>
</html>