我有以下要求获取注册表格来发布数据.但是我无法测试它,有人可以帮忙.我想看看数据是否正在传递?我有jquery cdn和jquery-validate.
我有那个傻瓜
jQuery的:
// Code goes here $(function() { /* Registration form for the website */ /* validation */ $("#register-form").validate({ rules: { firstName: { required: true }, lastName: { required: true }, userName: { required: true, minlength: 4 }, email: { required: true, email: true }, password: { required: true, minlength: 8, maxlength: 15 }, cpassword: { required: true, equalTo: '#password' }, }, messages: { userName: "please enter a valid user name", password: { required: "please provide a password", minlength: "password at least have 8 characters" }, email: "please enter a valid email address", cpassword: { required: "please retype your password", equalTo: "password doesn't match !" } }, submitHandler: submitForm }); /* validation */ /* form submit */ function submitForm() { var data = $("#register-form").serialize(); // var data={ // firstName: $('#firstName').val(), // } $.ajax({ url: 'http://localhost:8000?userName=&password=&firstName=&lastName=&email=', type: 'POST', data: data, beforeSend: function() { $("#error").fadeOut(); $("#btn-submit").html(' sending ...'); }, success: function(data) { if (data === 0) { $("#error").fadeIn(1000, function() { $("#error").html('Sorry email already taken !'); $("#btn-submit").html(' Create Account'); }); } else if (data == 1) { $("#btn-submit").html(' Signing Up ...'); } else { $("#error").fadeIn(1000, function() { $("#error").html('' + data + ' !'); $("#btn-submit").html(' Create Account'); }); } } }); return false; } });
小智.. 6
如果您检查浏览器,请转到网络选项卡.选择那里的XHR选项卡.这些都是AJAX调用.从这里您可以看到状态代码,持续时间等.
注意:这是Chrome浏览器的屏幕截图
如果您检查浏览器,请转到网络选项卡.选择那里的XHR选项卡.这些都是AJAX调用.从这里您可以看到状态代码,持续时间等.
注意:这是Chrome浏览器的屏幕截图