我有这个 ajax 请求工作,现在它已经停止了。我不相信我更改了任何代码,但谁知道呢。我确实下载并上传了一些新的 jquery,但 ajax 请求不使用 jquery。无论如何,这是一个足球比赛挑选网站,我需要快速修复它。我已经浏览了所有代码,如果有人可以修复它,那么他们一定是上帝。无论如何,只要图片符合截止日期,用户就会点击图片。单击图像时,它会进入功能“teamback”。它进入那里,但它不处理 ajax 请求。当用户选择图像时,它应该使用传递给函数的信息来更新数据库。我已经发布了所有的代码。请帮忙!!
这是用户进行选择的页面......(对不起,有这么多,在此之前还有更多的 php,但我 99% 确定没有必要。)
<?php
// this starts the session
session_start();
$id = $_SESSION['userid'];
$var = "";
$varcontact = "<a href='JavaScript:newPopup(\"http://www.yourfantasyfootballreality.com/contact.php\");' class='three'>Contact</a>";
// echo variable from the session, we set this on our other page
if ($_SESSION['userid'] == "") {
$var = "<a href='JavaScript:newPopup(\"http://www.yourfantasyfootballreality.com/register.html\");' class='two'>Register</a> | <a href='JavaScript:newPopup(\"http://www.yourfantasyfootballreality.com/signin.php\");' class='two'>Sign In</a>";
} else {
$var = "Hello, ".$_SESSION['userid'] ."! | " . "<a href=\"http://www.yourfantasyfootballreality.com/logout.php\" class='two'>Log Out</a>";
}
//this gets the name of the person selected in the league
$uniqueid = $_GET["id"];
$time = time();
$timedeadline = 1344700055;
//this connects to the database
$con = mysql_connect("localhost","credential","credential");
mysql_select_db("yourfan_demo", $con);
?>
<!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>
<script type="text/javascript" src="jquery-1.8.1.js"></script>
<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
<script type="text/javascript" src="js/coda-slider.1.1.1.pack.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="http://www.indiana.edu/favicon.ico" />
<title>YourFantasyFootballReality</title>
<link rel="stylesheet" type="text/css" href="stylenewarticle.css" />
<script type="text/javascript">
//*******COUNTDOWN TIMER******************//
CountDownTimer('09/05/2012 8:30 PM', 'newcountdown');
function CountDownTimer(dt, id)
{
var end = new Date(dt);
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance <= 0) {
//document.getElementById("newcountdown").style.font-size="1em";
clearInterval(timer);
document.getElementById("newcountdown").innerHTML = '00:00:00:00';
document.getElementById("newcountdown").style.color="red";
document.getElementById("newcountdown").style.border="3px dashed red";
document.getElementById("newcountdown").style.bgColor="#FF63AC";
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById("newcountdown").innerHTML = days + ':';
document.getElementById("newcountdown").innerHTML += hours + ':';
document.getElementById("newcountdown").innerHTML += minutes + ':';
document.getElementById("newcountdown").innerHTML += seconds + '';
}
timer = setInterval(showRemaining, 1000);
}
//****************************END OF COUNTDOWN TIMER****************//////
//this is the user id session stored as a javascript variable
var userid = "<?=$id?>";
var uniqueid = "<?=$uniqueid?>";
// Popup window code
function newPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=450,width=600,left=10,top=10,resizable=no,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
function bigimg(x) {
if (userid == uniqueid) {
var myDate = new Date(); // Your timezone!
var myEpoch = myDate.getTime()/1000;
var deadline = '1344700055.000';
//determines if user was on time..if not on time hover enlarge won't work
if(myEpoch > deadline) {
x.style.height="65px";
x.style.width="85px";
//x.style.opacity="0.5";
} else {}
} else {}
}
function defaultimg(x) {
x.style.height="60px";
x.style.width="80px";
x.style.opacity="1.0";
}
function teamback(x, act) {
if (uniqueid == userid) {
var myDate = new Date(); // Your timezone!
var myEpoch = myDate.getTime()/1000;
var deadline = '1344700055.000';
//determines if user was on time..if not on time submitting won't work
if(myEpoch > deadline) {
// update the "actualone" image's source to the sending-image's source
var tn = x.id;
var sc = x.name;
//THIS MUST BE CHANGED BASED ON THE WEEK!!!!!!!!!!!!
var week = 1;
document.getElementById(act).src = x.src;
document.getElementById("curtime").innerHTML = myEpoch;
document.getElementById("team").innerHTML = x.id;
document.getElementById("scenario").innerHTML = x.name;
//AJAX PART
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}}}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
//document.myForm.time.value = ajaxRequest.responseText;
}
}
//here is where we will use the variables userid, tn, and sc
var queryString = "?userid=" + userid + "&tn=" + tn + "&sc=" + sc + "&week=" + week;
ajaxRequest.open("GET", "makepick.php" + queryString, true);
ajaxRequest.send(null);
} else {}
} else {}
}
</script>
</head>
<body class="body">
<!--Container to hold everything in the middle of page-->
<div class="container">
<!--Facebook Like button-->
<iframe class="fb" src="" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
<!--Login and Register links-->
<div class="enter">
<?=$var?>
</div>
<!--Contains everything in the menu-->
<div class="menutest">
<!--the main menu links-->
<div id="navigation">
<ul>
<a class="topic" href="index.php"><li>Home</li></a>
<a class="topic" href="pickem.php"><li>Pick Em</li></a>
<a class="topic" href="projections.php"><li>Projections</li></a>
<a class="topic" href="stats.html"><li>Scoring Leaders</li></a>
<a class="topic" href="newarticle.php"><li>Articles</li></a>
</ul>
</div>
<!--the list of scores-->
<table id="schedule" border="1">
<tr>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> DAL @NYG</a></td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> IND @CHI</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> ATL @KC</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> PHI @CLE</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> WAS @NO</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> STL @DET</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> NE @TEN</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> JAC @MIN</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> BUF @NYJ</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> MIA @HOU</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> SEA @ARI</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> SF @GB</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> CAR @TB</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> PIT @DEN</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> CIN @BAL</td>
<td><a class="one" href="http://espn.go.com/nfl/boxscore?gameId=311002003"> SD @OAK</td>
</tr>
</table>
</div>
<!--the espn ticker-->
<div class="ticker">
<!--<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript">if (WIDGETBOX) WIDGETBOX.renderWidget('61d83c1a-939a-460b-8075-91c9e1473aff');</script>
<noscript>Get the <a href="http://www.widgetbox.com/widget/espns-bottom-line-version-20">ESPN's Bottom Line - Version 2.0</a> widget and many other <a href="http://www.widgetbox.com/">great free widgets</a> at <a href="http://www.widgetbox.com">Widgetbox</a>! Not seeing a widget? (<a href="http://support.widgetbox.com/">More info</a>)</noscript>
--></div>
<center><h1>Week 1</h1></center>
<center><div style="font-size:1.5em; font-weight:bold;">Time Remaining to Make Picks</div></center>
<center><div id="newcountdown" style="height:40px; width:300px; border:1; background-color:#BABABA; font-size:2em; border:2px ridge gray;"></div></center>
<!--<center><iframe style="background-color:pink;" src="http://free.timeanddate.com/countdown/i38ik9yz/n417/cf12/cm0/cu4/ct1/cs1/ca0/co1/cr0/ss0/cac000/cpc000/pct/tc66c/fs100/szw320/szh135/tatTime%20Remaining%20to%20Make%20Picks/tac000/tptTime%20Remaining%20to%20Make%20Picks/tpc000/iso2012-08-11T13:00:00/bas2/bat2/bacf00" frameborder="0" width="268" height="40"></iframe></center>-->
<center><h4><a href="leaguehome.php"><?=$leaguename?></a> : <?=$id?></h4><?echo "Viewing " . $uniqueid . "'s Profile...";?></center>
<center><div style="width:500px; color:white; font-weight:bold;">Week: <a class="two" href="2012week1.php?id=<? echo $uniqueid?>">1 </a><a class="two" href="2012week2.php?id=<? echo $uniqueid?>">2 </a><a class="two" href="2012week3.php?id=<? echo $uniqueid?>">3 </a>
<a class="two" href="2012week4.php?id=<? echo $uniqueid?>">4 </a><a class="two" href="2012week5.php?id=<? echo $uniqueid?>">5 </a><a class="two" href="2012week6.php?id=<? echo $uniqueid?>">6 </a><a class="two" href="2012week7.php?id=<? echo $uniqueid?>">7 </a>
<a class="two" href="2012week8.php?id=<? echo $uniqueid?>">8 </a><a class="two" href="2012week9.php?id=<? echo $uniqueid?>">9 </a><a class="two" href="2012week10.php?id=<? echo $uniqueid?>">10 </a><a class="two" href="2012week11.php?id=<? echo $uniqueid?>">11 </a>
<a class="two" href="2012week12.php?id=<? echo $uniqueid?>">12 </a><a class="two" href="2012week13.php?id=<? echo $uniqueid?>">13 </a><a class="two" href="2012week14.php?id=<? echo $uniqueid?>">14 </a><a class="two" href="2012week15.php?id=<? echo $uniqueid?>">15 </a>
<a class="two" href="2012week16.php?id=<? echo $uniqueid?>">16 </a><a class="two" href="2012week17.php?id=<? echo $uniqueid?>">17 </a><a class="two" href="2012weekwc.php?id=<? echo $uniqueid?>">WC </a><a class="two" href="2012weekdiv.php?id=<? echo $uniqueid?>">DIV </a>
<a class="two" href="2012weekconf.php?id=<? echo $uniqueid?>">CONF </a><a class="two" href="2012weeksb.php?id=<? echo $uniqueid?>">SB </a> </div></center>
<center><table border="1" style="background-color:white;">
<tr>
<th>Game</th>
<th>Your Pick</th>
<th>Picks Correct</th>
<th>Points Earned</th>
</tr>
<tr>
<td><img id="cowboys" name="One" onmouseover="bigimg(this)" onclick="teamback(this, 'actualone')" onmouseout="defaultimg(this)" src="cowboys.gif"> vs <img id="giants" name="One" onmouseover="bigimg(this)" onclick="teamback(this, 'actualone')" onmouseout="defaultimg(this)" src="giants.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>2 ODDS 1</center></div></td>
<td><img src="<?=$One?>" id="actualone" style="width:85px; height:65px;"></td>
<td><center><?=$Ones?></center></td>
<td><center><?=$Onep?></center></td>
</tr>
<tr>
<td><img id="colts" name="Two" onmouseover="bigimg(this)" onclick="teamback(this, 'actualtwo')" onmouseout="defaultimg(this)" src="colts.gif"> vs <img id="bears" name="Two" onmouseover="bigimg(this)" onclick="teamback(this, 'actualtwo')" onmouseout="defaultimg(this)" src="bears.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>5 ODDS 1</center></div></td>
<td><img src="<?=$Two?>" id="actualtwo" style="width:85px; height:65px;"></td>
<td><center><?=$Twos?></center></td>
<td><center><?=$Twop?></center></td>
</tr>
<tr>
<td><img id="eagles" name="Three" onmouseover="bigimg(this)" onclick="teamback(this, 'actualthree')" onmouseout="defaultimg(this)" src="eagles.gif"> vs <img id="browns" name="Three" onmouseover="bigimg(this)" onclick="teamback(this, 'actualthree')" onmouseout="defaultimg(this)" src="browns.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 4</center></div></td>
<td><img src="<?=$Three?>" id="actualthree" style="width:85px; height:65px;"></td>
<td><center><?=$Threes?></center></td>
<td><center><?=$Threep?></center></td>
</tr>
<tr>
<td><img id="patriots" name="Four" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfour')" onmouseout="defaultimg(this)" src="patriots.gif"> vs <img id="titans" name="Four" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfour')" onmouseout="defaultimg(this)" src="titans.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 3</center></div></td>
<td><img src="<?=$Four?>" id="actualfour" style="width:85px; height:65px;"></td>
<td><center><?=$Fours?></center></td>
<td><center><?=$Fourp?></center></td>
</tr>
<tr>
<td><img id="falcons" name="Five" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfive')" onmouseout="defaultimg(this)" src="falcons.gif"> vs <img id="chiefs" name="Five" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfive')" onmouseout="defaultimg(this)" src="chiefs.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Five?>" id="actualfive" style="width:85px; height:65px;"></td>
<td><center><?=$Fives?></center></td>
<td><center><?=$Fivep?></center></td>
</tr>
<tr>
<td><img id="jaguars" name="Six" onmouseover="bigimg(this)" onclick="teamback(this, 'actualsix')" onmouseout="defaultimg(this)" src="jaguars.gif"> vs <img id="vikings" name="Six" onmouseover="bigimg(this)" onclick="teamback(this, 'actualsix')" onmouseout="defaultimg(this)" src="vikings.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>2 ODDS 1</center></div></td>
<td><img src="<?=$Six?>" id="actualsix" style="width:85px; height:65px;"></td>
<td><center><?=$Sixs?></center></td>
<td><center><?=$Sixp?></center></td>
</tr>
<tr>
<td><img id="redskins" name="Seven" onmouseover="bigimg(this)" onclick="teamback(this, 'actualseven')" onmouseout="defaultimg(this)" src="redskins.gif"> vs <img id="saints" name="Seven" onmouseover="bigimg(this)" onclick="teamback(this, 'actualseven')" onmouseout="defaultimg(this)" src="saints.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>5 ODDS 1</center></div></td>
<td><img src="<?=$Seven?>" id="actualseven" style="width:85px; height:65px;"></td>
<td><center><?=$Sevens?></center></td>
<td><center><?=$Sevenp?></center></td>
</tr>
<tr>
<td><img id="bills" name="Eight" onmouseover="bigimg(this)" onclick="teamback(this, 'actualeight')" onmouseout="defaultimg(this)" src="bills.gif"> vs <img id="jets" name="Eight" onmouseover="bigimg(this)" onclick="teamback(this, 'actualeight')" onmouseout="defaultimg(this)" src="jets.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Eight?>" id="actualeight" style="width:85px; height:65px;"></td>
<td><center><?=$Eights?></center></td>
<td><center><?=$Eightp?></center></td>
</tr>
<tr>
<td><img id="rams" name="Nine" onmouseover="bigimg(this)" onclick="teamback(this, 'actualnine')" onmouseout="defaultimg(this)" src="rams.gif"> vs <img id="lions" name="Nine" onmouseover="bigimg(this)" onclick="teamback(this, 'actualnine')" onmouseout="defaultimg(this)" src="lions.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>4 ODDS 1</center></div></td>
<td><img src="<?=$Nine?>" id="actualnine" style="width:85px; height:65px;"></td>
<td><center><?=$Nines?></center></td>
<td><center><?=$Ninep?></center></td>
</tr>
<tr>
<td><img id="dolphins" name="Ten" onmouseover="bigimg(this)" onclick="teamback(this, 'actualten')" onmouseout="defaultimg(this)" src="dolphins.gif"> vs <img id="texans" name="Ten" onmouseover="bigimg(this)" onclick="teamback(this, 'actualten')" onmouseout="defaultimg(this)" src="texans.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>4 ODDS 1</center></div></td>
<td><img src="<?=$Ten?>" id="actualten" style="width:85px; height:65px;"></td>
<td><center><?=$Tens?></center></td>
<td><center><?=$Tenp?></center></td>
</tr>
<tr>
<td><img id="49ers" name="Eleven" onmouseover="bigimg(this)" onclick="teamback(this, 'actualeleven')" onmouseout="defaultimg(this)" src="49ers.gif"> vs <img id="packers" name="Eleven" onmouseover="bigimg(this)" onclick="teamback(this, 'actualeleven')" onmouseout="defaultimg(this)" src="packers.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>2 ODDS 1</center></div></td>
<td><img src="<?=$Eleven?>" id="actualeleven" style="width:85px; height:65px;"></td>
<td><center><?=$Elevens?></center></td>
<td><center><?=$Elevenp?></center></td>
</tr>
<tr>
<td><img id="seahawks" name="Twelve" onmouseover="bigimg(this)" onclick="teamback(this, 'actualtwelve')" onmouseout="defaultimg(this)" src="seahawks.gif"> vs <img id="cardinals" name="Twelve" onmouseover="bigimg(this)" onclick="teamback(this, 'actualtwelve')" onmouseout="defaultimg(this)" src="cardinals.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Twelve?>" id="actualtwelve" style="width:85px; height:65px;"></td>
<td><center><?=$Twelves?></center></td>
<td><center><?=$Twelvep?></center></td>
</tr>
<tr>
<td><img id="panthers" name="Thirteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualthirteen')" onmouseout="defaultimg(this)" src="panthers.gif"> vs <img id="buccaneers" name="Thirteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualthirteen')" onmouseout="defaultimg(this)" src="buccaneers.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Thirteen?>" id="actualthirteen" style="width:85px; height:65px;"></td>
<td><center><?=$Thirteens?></center></td>
<td><center><?=$Thirteenp?></center></td>
</tr>
<tr>
<td><img id="steelers" name="Fourteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfourteen')" onmouseout="defaultimg(this)" src="steelers.gif"> vs <img id="broncos" name="Fourteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfourteen')" onmouseout="defaultimg(this)" src="broncos.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Fourteen?>" id="actualfourteen" style="width:85px; height:65px;"></td>
<td><center><?=$Fourteens?></center></td>
<td><center><?=$Fourteenp?></center></td>
</tr>
<tr>
<td><img id="bengals" name="fifteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfifteen')" onmouseout="defaultimg(this)" src="bengals.gif"> vs <img id="ravens" name="Fifteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualfifteen')" onmouseout="defaultimg(this)" src="ravens.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>2 ODDS 1</center></div></td>
<td><img src="<?=$Fifteen?>" id="actualfifteen" style="width:85px; height:65px;"></td>
<td><center><?=$Fifteens?></center></td>
<td><center><?=$Fifteenp?></center></td>
</tr>
<tr>
<td><img id="chargers" name="Sixteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualsixteen')" onmouseout="defaultimg(this)" src="chargers.gif"> vs <img id="raiders" name="Sixteen" onmouseover="bigimg(this)" onclick="teamback(this, 'actualsixteen')" onmouseout="defaultimg(this)" src="raiders.gif">
<br><div style="background-color:gray; width:180px; height:20px"><center>1 ODDS 1</center></div></td>
<td><img src="<?=$Sixteen?>" id="actualsixteen" style="width:85px; height:65px;"></td>
<td><center><?=$Sixteens?></center></td>
<td><center><?=$Sixteenp?></center></td>
</tr>
<tr><td><center>Totals</center></td><td></td><td><center><?=$Week_Selections?></center></td><td><b><center><?=$Week_Points?></center></b></td></tr>
</table></center>
</div>
</body>
</html>
这里是 makepick.php ajax 请求更新数据库的地方......
<?php
//this connects to the database
$con = mysql_connect("localhost","yourfan_jeengle","armyjoe");
mysql_select_db("yourfan_demo", $con);
$userid = $_GET["userid"];
$tn = $_GET["tn"];
$sc = $_GET["sc"];
$wk = $_GET["week"];
mysql_query("UPDATE `Week{$wk}_Picks` SET `$sc` = '$tn' WHERE UserID = '$userid'");
?>