我有一個關於我的代碼在ajax的問題。警報總是彈出使用ajax
AJAX
<script type="text/javascript">
var stopTime =0;
var scoreCheck = function()
{
$.ajax({
url: 'http://127.0.0.1/ProgVsProg/main/checkScoreRoundOne',
success:function(output){
if(output !=' '){
$('#maincontent1').html(output);
bootbox.alert("We have a winner", function(){
});
stopTime = setTimeout(scoreCheck, 1000);
}
else {
clearTimeout(stopTime);
}
}
});
}
stopTime = setTimeout(scoreCheck,1000);
</script>
控制器
public function checkScoreRoundOne(){
$id = $this->session->userdata('userID');
$battleID = $this->lawmodel->getBattle($id);
foreach($battleID as $row){
$Rscore = $row->requestedScore;
$Cscore = $row->challengerScore;
if($Cscore == '1'){
$rID = $this->lawmodel->getID($row->challengerID);
foreach($rID as $row){
echo $row->username."Got the correct answer";
}
}
else if($Rscore == '1'){
$cID =$this->lawmodel->getID($row->requestedID);
foreach($cID as $row){
echo $row->username."Got the correct answer";
}
}
else
echo "Answer the question";
}
}
我的問題是AJAX會時刻警惕,即使它不符合我的控制器的條件。 我不能測試我的項目,如果它是正確的,或者使用笨not..Im ..
進出口新的阿賈克斯PLSS幫助.. :( 編輯
我怎樣才能使警報彈出只有當它滿足條件在我的控制器?:( 就像當Cscore ==「1」的警報會彈出..
什麼是你想怎麼辦?從你的問題 – Steve
編輯已經不明顯..sorry..im不是很明確.. :( – Zurreal