I have this Javascript function:
function capitalizeFL(string) { //takes a string, returns it with first letter capitalized
return string.charAt(0).toUpperCase() + string.slice(1);
}
A file called statuswindow.php, which includes the following:
<?php
$raceV = "<script>document.write(capitalizeFL(\"".$player->race."\"));</script>";
$clasV = "<script>document.write(capitalizeFL(\"".$player->clas."\"));</script>";
echo "You have chosen a " . $raceV. " " .$clasV ."!";
?>
Now the main file, which uses ajax to update and show the player's class and race ($clas, $race), after capitalizing their first letters using capitalizeFL:
Main file includes the following:
$("button").click(function() {
$("#topMenu").load("statuswindow.php");
});
What I would LIKE to happen, is that the html from statuswindow.php will be properly displayed in the main window's #topMenu div.
I'm assuming the problem is due to document.write overwriting the whole page. The question is, how can I do the following, without using document.write?