请考虑我正在尝试集成的以下代码行:
第一部分:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
第二部分:
<script> var processFinish = false;
var tf_dialog_count;
var tf_dialog_counter;
function verifyMe(u,key,fname,status)
{
if(processFinish)
{
tf_dialog_count = 0;
return true; }
else {
if(typeof status === 'undefined')
{ $("body").append("<div id='tf_dialog'><p></p></div>");
var unameVal = $("#"+u).val();
var surl = 'http://someurl.com/username/filename.cfc?method=generateToken&uname='+unameVal+'&key='+key+'&callback=?';
var retRes = false;
$.getJSON(surl, function(data)
{
if(parseInt(data.RESULT) == 1)
{ $("#tf_dialog").html(data.MSG);
$("#tf_dialog").append("<br>Time Remaining <span id='tf_dialog_counter'></span> secs");
$("#tf_dialog").append("<br><span id='tf_dialog_waiting'>Waiting</span>");
$("#tf_dialog").dialog({ height: 200 });
tf_dialog_count = 20;
tf_dialog_counter=setInterval(timer, 1000);
setInterval(function() { verifyMe(unameVal,key,fname,'checkStatus'); },7000);
return false; }
else {
alert(data.MSG);
return false;
} }) }
else { if (tf_dialog_count > 0)
{ var surl = 'http://someurl.com/username/filename.cfc?method=getStatus&uname='+u+'&key='+key+'&callback=?';
$.getJSON(surl, function(data) { $("#tf_dialog_waiting").animate({fontSize:"22px"},3500,function(){ $(this).animate({fontSize:"10px"},3500); });
if(parseInt(data.RESULT) == 1)
{ processFinish = true; $('#'+fname).submit(); }
else { return false; } });
} } return false; } }
function timer()
{ tf_dialog_count=tf_dialog_count-1;
if (tf_dialog_count <= 0)
{ clearInterval(tf_dialog_counter); processFinish = false;
$("#tf_dialog").html("");
$("#tf_dialog").dialog("destroy");
$("#tf_dialog").remove();
alert("Time out. Please try again!!");
} $('#tf_dialog_counter').html(tf_dialog_count);
} </script>
第三部分:
我需要为onSubmit
属性添加以下代码:
return verifyMe('<username_textbox_id>','<key>','<form_id>')
我创建了一个登录表单(ColdFusion)并尝试运行代码,但想知道我的代码有什么问题。如果我输入错误的变量,请告诉我。
这是迄今为止我在 Dreamweaver 中使用的全部代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Form</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script> var processFinish = false;
var tf_dialog_count;
var tf_dialog_counter;
function verifyMe(u,key,fname,status)
{
if(processFinish)
{
tf_dialog_count = 0;
return true; }
else {
if(typeof status === 'undefined')
{ $("body").append("<div id='tf_dialog'><p></p></div>");
var unameVal = $("#"+u).val();
var surl = 'http://someurl.com/username/filename.cfc?method=generateToken&uname='+unameVal+'&key='+key+'&callback=?';
var retRes = false;
$.getJSON(surl, function(data)
{
if(parseInt(data.RESULT) == 1)
{ $("#tf_dialog").html(data.MSG);
$("#tf_dialog").append("<br>Time Remaining <span id='tf_dialog_counter'></span> secs");
$("#tf_dialog").append("<br><span id='tf_dialog_waiting'>Waiting</span>");
$("#tf_dialog").dialog({ height: 200 });
tf_dialog_count = 20;
tf_dialog_counter=setInterval(timer, 1000);
setInterval(function() { verifyMe(unameVal,key,fname,'checkStatus'); },7000);
return false; }
else {
alert(data.MSG);
return false;
} }) }
else { if (tf_dialog_count > 0)
{ var surl = 'http://someurl.com/username/filename.cfc?method=getStatus&uname='+u+'&key='+key+'&callback=?';
$.getJSON(surl, function(data) { $("#tf_dialog_waiting").animate({fontSize:"22px"},3500,function(){ $(this).animate({fontSize:"10px"},3500); });
if(parseInt(data.RESULT) == 1)
{ processFinish = true; $('#'+fname).submit(); }
else { return false; } });
} } return false; } }
function timer()
{ tf_dialog_count=tf_dialog_count-1;
if (tf_dialog_count <= 0)
{ clearInterval(tf_dialog_counter); processFinish = false;
$("#tf_dialog").html("");
$("#tf_dialog").dialog("destroy");
$("#tf_dialog").remove();
alert("Time out. Please try again!!");
} $('#tf_dialog_counter').html(tf_dialog_count);
} </script>
</head>
<body>
<p> </p>
<div align = "center">
<cfform id = "form_id" action="" method="POST" onSubmit = "return verifyMe('<username_textbox_id>','<key>','<form_id>')">
Username:<br>
<br/>
<cfinput type="text" name="uname" id = "uname" />
<br>
<p> </p>
Password:<br/>
<br/>
<cfinput type="password" name="pwd" id="pwd" /><br>
<p> </p>
<cfinput type="submit" name="submit" value="Submit" />
</cfform>
</div>
</body>
</html>