3
I made a code in AJAX runs PHP and prints in HTML the result of the SQL query, the problem is that when it displays on the screen, the data is not processed, stay like this:
What I need is simply that on the screen appear only the content of 'ayzac_episode_name', but I can not lose the other information (mainly 'ayzac_episode_id')
follow the codes:
AJAX:
function searchEpisode(seasonID,divepisodioID) {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "../control/ayzac_control_getEpisode.php?id=" + seasonID;
req.open("Get", url, true);
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
var answer = req.responseText;
alert(answer);
document.getElementById("episodios" + divepisodioID).innerHTML = answer;
}
}
PHP(function that searches the episode):
function getSerieEpisodes($seasonID){
$connect = new ControllerConnect ();
$objCon = $connect->controllerConnect ();
$sql = "SELECT * FROM ayzac_episode WHERE ayzac_season_id = '".$seasonID."'";
return $objCon->executeSQLFetchObjectEpisodes($sql);
}
PHP (executeSQLFetchObjectEpisodes):
function executeSQLFetchObjectEpisodes($sql = NULL) {
if ($sql != NULL) {
$query = mysqli_query ( $this->con, $sql );
while ( $result = mysqli_fetch_object ( $query ) ) {
$this->rows [] = $result;
}
if ($this->rows != null) {
return $this->rows;
}
return false;
} else {
return false;
}
}