Skip to content

Instantly share code, notes, and snippets.

@ckentq
Created July 18, 2014 02:10
Show Gist options
  • Save ckentq/684b2b887a70e4d5ab8b to your computer and use it in GitHub Desktop.
Save ckentq/684b2b887a70e4d5ab8b to your computer and use it in GitHub Desktop.
var _new_id = 0;
// check only code
var currentTimer = 0;
var _code = '';
checkIt = function(){
if(_code == ''){
$('#check_result').html('代碼不可為空白');
}else{
$('#waiting').show();
$.post(_page_url+"/check_code", { code: _code},
function(data){
$('#waiting').hide();
if(data['result']) {
$('#check_result').html('代碼可使用');
}else{
$('#check_result').html('代碼已存在');
}
}, "json");
}
}
$('#check_code').on('keyup', function(){
_code = $(this).val();
clearTimeout(currentTimer);
currentTimer = setTimeout("checkIt()", 800);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment