[英]What does this Javascript Sign up Code do?
It is related to an ajax/jquery 1.3.2 based sign up form. 它与基于ajax / jquery 1.3.2的注册表单有关。 I want to learn how to make this and use jquery in general by understanding the code/syntax line by line.
我想通过逐行理解代码/语法来学习如何制作并一般使用jquery。
Can someone explain what this code is trying to accomplish and how it does so line by line? 有人可以解释此代码试图完成的内容以及如何逐行执行吗?
<script type="text/javascript">
$(document).ready(function(){
// Email Signup
$("form#sub_name").submit(function() {
var dataStr = $("#UserEmail").val();
$.ajax({
type: "POST",
url: "signup.php",
data : {UserEmail: dataStr},
success: function(del){
$("#signup-success").html(del);
$("#signup-success").fadeIn();
$('#signup-success').fadeOut(10000);
}
});
return false;
});
});
Thanks! 谢谢!
Code explained in the comments. 注释中解释了代码。
<script type="text/javascript">
$(document).ready(function(){ // run this code on page load
// Email Signup
$("form#sub_name").submit(function() { // activate on form submit for sign in
// the id of the form is sub_name
var dataStr = $("#UserEmail").val(); // get the email address from an
// input field with ID UserEmail
$.ajax({ // use and ajax call to signup.php
// using POST method
type: "POST",
url: "signup.php",
data : {UserEmail: dataStr}, // The parameter UserEmail is passed.
success: function(del){ // this part displays the success
$("#signup-success").html(del); // probably a div with id signup-success
$("#signup-success").fadeIn(); // is faded in and
$('#signup-success').fadeOut(10000); // removed after 10 seconds
}
});
return false;
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.