我有一个html文件,其内容如下所示,我想在点击提交按钮时将数据发布到某个网页。但是,我没有在jquery方面看到任何行动。有人可以启发我,有什么不对吗?
<HTML>
<HEAD>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script>
$("#emailSubmit).click(function(){
$.post("mytest.asp",
{
name: "Donald Duck",
city: "Duckburg"
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
</script>
<STYLE>
.buttonholder{border:0px solid gray;height:30px;width:200px;position:relative;color:gray;margin:10px}
.holder{border:2px solid gray;height:30px;width:200px;position:relative;color:gray;margin:10px}
div.holder:hover{border:2px solid #33b5e5}
.holder input[type=text]{height:28px;border:0;width:95%;font-weight:700;outline:none;color:gray;font-size:18px;padding-left:5px;padding-right:5px}
.holder input[type=text]:focus{color:#000}
.holder input[type=text]:focus[required=required]{background-color:#f1d1d1}
.holder input[type=email]{height:28px;border:0;width:95%;font-weight:700;outline:none;color:gray;font-size:18px;padding-left:5px;padding-right:5px}
.holder input[type=email]:focus{color:#000}
.holder input[type=email]:focus[required=required]{background-color:#f1d1d1}
.holder .mask-left{position:absolute;top:-2px;left:-2px;width:2px;height:80%;background-color:#fff}
.holder .mask-right{position:absolute;top:-2px;right:-2px;width:2px;height:80%;background-color:#fff}
.holder .mask-top{position:absolute;top:-2px;left:0;width:100%;height:2px;background-color:#fff}
</STYLE>
</HEAD>
<BODY>
<form id="ccSelectForm">
<img src="./gettrixwhite.png" alt="My logo" align="middle" >
<div class="holder">
<input type="text" id="inputFirstName" placeholder="First Name *" required="required" />
<div class="mask-left"></div>
<div class="mask-right"></div>
<div class="mask-top"></div>
</div>
<div class="holder">
<input type="text" id="inputLastName" placeholder="Last Name *" required="required" />
<div class="mask-left"></div>
<div class="mask-right"></div>
<div class="mask-top"></div>
</div>
<div class="holder">
<input type="email" id="inputEmail" placeholder="Email *" required="required" />
<div class="mask-left"></div>
<div class="mask-right"></div>
<div class="mask-top"></div>
</div>
<div class="buttonholder">
<button type="button" id="emailSubmit" class="btn btn-danger" data-toggle="tooltip" data-placement="bottom" title="Click here to sign up">Sign me up. »</button>
</div>
</form>
</BODY>
</HTML>
答案 0 :(得分:1)
在dom准备就绪后触发click
事件。
$(function() {
$('#emailSubmit').click(function(){
$.post("mytest.asp",
{
name: "Donald Duck",
city: "Duckburg"
},
function(data){
// make sure you are returing something.
alert("Data: " + data);
});
});
});
答案 1 :(得分:1)
您有语法错误:
$("#emailSubmit) //missing quotes at end
你还需要准备好dom:
$(function() {
// your code here
});