javascript - Ajax, Can't load xml data -
while trying load xml data trough ajax not working.. can't see data display..
var xmlhttp = createxmlhttpreq(); function createxmlhttpreq() { var xmlhttp; try { xmlhttp = new xmlhttprequest(); } catch (e) { try { xmlhttp = new activexobject("microsogt.xmlhttp"); } catch (e) { alert("not supported browser"); } } return xmlhttp; } function exam(id) { if (xmlhttp.readystate == 0 || xmlhttp.readystate == 4) { xmlhttp.open("get", "examajax.php?id=" + id, true); xmlhttp.onreadystatechange = handleresponse; xmlhttp.send(); } else { settimeout(exam(), 1000); } } function handleresponse() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { data = xmlhttp.responsexml.documentelement.firstchild.data; document.getelementbyid("mainform").innerhtml = data; } }
examajax.php file :
<?php header("content-type : text/xml"); echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; echo '<response>'; $id = isset($_get['id']) ? intval($_get['id']) : 0; $p = isset($_get['s_p']) ? intval($_get['s_p']) : 1; $loadall = mysql_query("select * `questions` `testid` = $id"); $ofp = mysql_num_rows($loadall); $selected = (isset($_get['sel']) && is_numeric($_get['sel']) && $_get['sel'] <= $ofp && $_get['sel'] >= 1) ? $_session['sel'.$p] = intval($_get['sel']) : null; $loadquestion = mysql_query("select * `questions` `testid` = $id && `pos` = $p order -`id` desc limit 1"); while ($question = mysql_fetch_array($loadquestion)) { ?> שאלה <?php echo $p; ?>/<?php echo $ofp; ?> <?php echo $question['name']; ?> <input type="radio" onclick="select(1,<?php echo $p; ?>)" value="<?php echo $question['op1']; ?>" /> <input type="radio" onclick="select(2,<?php echo $p; ?>)" value="<?php echo $question['op2']; ?>" /> <input type="radio" onclick="select(3,<?php echo $p; ?>)" value="<?php echo $question['op3']; ?>" /> <input type="radio" onclick="select(4,<?php echo $p; ?>)" value="<?php echo $question['op4']; ?>" /> <input type="radio" onclick="select(5,<?php echo $p; ?>)" value="<?php echo $question['op5']; ?>" /> <?php } echo '</response'; ?>
if i'm changing innerhtml string instead of data display string .. reason doesn't load xml data.. please?
Comments
Post a Comment