0
上記のクエリの結果が真であるときにカウントダウン関数を呼び出すときに問題があります。基本的に、スクリプトは、ユーザーが権限を持っているかどうかをチェックし、権限がある場合はメッセージを表示し、カウントダウンして新しいページにリダイレクトします。私は、構文チェッカーを介してコードを実行し、それが有効に出てくる。条件が真のときに関数を呼び出す
しかし、ブラウザのデバッガの検査で、私は 'カウントダウン'のエラーが発生するのは不明です。私がここで間違っていることをはっきりとは分かりません。
function validate() {
var userName = $().SPServices.SPGetCurrentUser({
fieldName: "UserName"
});
var query = '<Query>' +
'<Where>' +
'<Eq>' +
'<FieldRef Name="userid" />' +
'<Value Type="User">' + userName + '</Value>' +
'</Eq>' +
'</Where>' +
'</Query>';
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "test",
CAMLViewFields: "<ViewFields><FieldRef Name='userid' /></ViewFields>",
completefunc: function(xData, Status) {
var matchFound = false; //define flag
$(xData.responseXML).SPFilterNode("z:row").each(function() {
if (userName == $(this).attr("ows_userid")) {
matchFound = true; //set the flag to true indicating matched record
}
function countdown() {
var time_left = 5;
var cinterval;
var timestatus = 1;
var targetURL = "http://www.google.com"
function time_dec() {
time_left--;
document.getElementById('countdown').innerHTML = time_left;
if (time_left == 0) {
clearInterval(cinterval);
window.location = targetURL
}
}
function defaultstart() {
time_left = 5;
clearInterval(cinterval);
cinterval = setInterval('time_dec()', 1000);
}
defaultstart();
}
});
if (matchFound)
$('#validmsg').css('visibility', 'visible');
else
$('#denymsg').css('visibility', 'visible');
if (matchFound) {
countdown()
}
}
});
});
}
どのエラーが参照されていますか? –
@RScott次回は質問をしています。それはユーザーがそれをよりよく読むのを助けるでしょう。 – sam
コードを書式設定した後、その答えは明らかです。それは範囲外です。常にコードを書式設定するか、この問題が常に発生します。 –