AJAX发布现场完成?
I have the code below that validates a form field called lms_domain. It simply checks whether the subdomain selected by the user is available using an AJAX call to another file that executes a MySQLi count query. The code currently works on submission of the form but I would like it to execute the AJAX post when the user types into the field, or has completed the field. How do you achieve this using JQuery?
$('#lms_name').keyup(function(){
/* some code here */
$.ajax({
type: 'POST',
url: 'assets/lmsdomaincheck.php',
data: "lmsdomain="+value+".thedomain.com",
async: false,
success: function(htmldata){
if (htmldata=="success") {
$('#spanlmsdomain').html('GOOD');
}else {
msg+="<b>Error on LMS domain name : </b>"+value+".thedomain.com not available.<br/>";
$('#spanlmsdomain').html('BAD');
}
}
});
/* some code here */
});
Thanks in advance for any tips!
weixin_33739523
2014/04/06 12:51- ajax
- validation
- jquery
- 点赞
- 收藏
- 回答
3个回复
