i'm a beginner at web development, so i'm having a hard time on this problem,i'm trying to make a website that gets stats from any player from a game that i play, it works by typing the player's name on the textbox then when you click on 'ok' it calls a js function that calls a php function that gets the xml on the game website api then print the results , when using my local server (apache) everything runs smoothly, no errors, but when i upload the files to my host the variable is not being passed, and i'm not sure why, here's the url to my web site www.statsofnewerth.sevencut.com.br/playerStats.php, just type my username in the box "Alcartur", then it should return one of my stats, but it's just blank, i put an alert to show the nick variable and the value returned, here's the code :
playerStats.php
<div class="search-panel">
<label>Search for player:</label>
<input name="playerName" id="txt_playerName" type="text" value="" size="20" maxlength="20" />
<input name="btnPlayerSearch" type="button" value="Ok" onclick="requestPlayerData()" />
</div>
form.js
function requestPlayerData(){
var img = new Image();
img.src = "src/wait.gif";
document.getElementById('wait-panel').innerHTML = "";
document.getElementById('wait-panel').appendChild(img);
var nickname = document.getElementById('txt_playerName').value;
ajaxFunction(nickname);
}
function ajaxFunction(nickname){
$('#wait-panel').load("httpRequest.php?nickname="+nickname, function(html){
alert(html);
});
}
and httpRequest.php
<?php
header('Content-type: application/xml');
$q = $_GET['nickname'];
echo 'nickname'.$q;
$sxe = simplexml_load_file('http://xml.heroesofnewerth.com/xml_requester.php?f=player_stats&opt=nick&nick[]='.$q);
$resul开发者_如何学Ct = $sxe->xpath("//*[@name='rnk_amm_team_rating']");
print_r($result);
?>
just remembering that in my local server it works.
Sry for any english mistakes, it's not my first language. Thanks in advance.
is data loaded at all?
$sxe = simplexml_load_file('http://xml.heroesofnewerth.com/xml_requester.php?f=player_stats&opt=nick&nick[]='.$q);
var_dump($sxe);die();
Make sure your httpRequest page is returning the correct data. I don't think it is.
<?php
header('Content-type: application/xml');
$q = $_GET['nickname'];
echo 'nickname'.$q;
$sxe = simplexml_load_file('http://xml.heroesofnewerth.com/xml_requester.php?f=player_stats&opt=nick&nick[]='.$q);
$result = $sxe->xpath("//*[@name='rnk_amm_team_rating']");
//print_r($result); // I don't think this can work? could be wrong
echo $result[0]; // this returns the first xpath match and outputs the value of the node, which is the "rnk_amm_team_rating" thing
// since this php says it returns XML (the header line), it should either do so or get rid of the header.
?>
Guys i found out the solution, even though i was putting the files on the remote server i think when i acessed the site it was using some old file from some cache in my computer(does it even make sense?), or it was some problem with the host, i don't really know, but now i did a refresh on the wesite and it was working normaly, if anyone have any idea of what might have happened i would like to hear. Thanks problem solved.
精彩评论