FirefoxとSafariで発生する問題がありますが、Chromeでは正常に動作します。
このjavascript配列には、一度に1つずつ表示するクイズの質問が含まれています。ただし、すべてのレコードが繰り返されるわけではありません。私はコンソールを使用しました、そしてそれは間違いなくすべての質問をロードしています、しかしそれでも時々レコードをスキップします(通常最初のものだけ)。
編集:クイズでこの配列が機能することに気づきました。すべての質問IDが順番に並んでいます。つまり、配列内の290,291,293です。しかし、機能していない例では、クイズIDはこの順序であり、286、285、287、288、および285がスキップされます。これは、問題の一部である可能性があります。
これが私のJavascript配列コードです。この問題を解決するのを手伝ってください。
var currentquestion;
jQuery.ajax({
url:"quizajax.php",
dataType: "json",
data: {
quizidvalue: <?=$thisquizid?>
},
}).done(function(data) {
questions = data;
for(i in data){
console.log(data[i]);
}
});
function nextQuestion (){
for(i in questions) {
if(i<=currentquestion)
continue;
currentquestion = i;
for(y in questions[i]) {
console.log("CurrentA: "+ currentquestion);
console.log("I: " + i);
console.log(questions[i][y].answerid);
}
console.log("CurrentQ: "+ currentquestion);
console.log("I: " + i);
console.log(questions[i]);
questionVariables ();
break;
}
dbからのサンプルコード、
questionid | quizid | questiontype | qdescription | qfilelocation | noofanswers | answertype
------------+--------+--------------+------------------+------------------------------------+-------------+------------
285 | 55 | text | 6 answer text | null | 6 | text
287 | 55 | text | 4ans text q | null | 4 | text
289 | 55 | text | 2 answers text q | null | 2 | text
286 | 55 | text | 5 answer text q | null | 5 | text
288 | 55 | text | 3 answer text q | null | 3 | text
290 | 55 | image | image q and a | image/55/712013a88298585d415c.jpeg | 4 | image
291 | 55 | video | video q and a | video/55/8efa10195f0c20d1254f.mp4 | 4 | video