View Single Post
Old 02-22-2012, 02:20 PM   PM User | #1
mdviky87
New to the CF scene

 
Join Date: Feb 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
mdviky87 is an unknown quantity at this point
Exclamation split response text in ajax

I want to split response text in ajax and display in two places in php using document.getElementById



this is my js

Code:
function approve(e) {
	var req = getXMLHTTP();
	if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						var resp = req.responseText;
						
						document.getElementById("get"+e).innerHTML=req.responseText;
						<!--document.getElementById("status").innerHTML=;-->
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", "approve.php?stu="+e, true);
			req.send(null);
		}
	}
Code:
<html>
<head><link rel="stylesheet" type="text/css" href="sts_style.css"  /></head>
<body>
<?php
	require_once 'connect.php';
	$id = $_REQUEST['stu'];
	$upd = mysql_query ("UPDATE stud SET approve = '1' WHERE s_id = ".$id." ");
	if ($upd) {
		//<div class="c_seven" id="get"><p class="text"></p></div>			
		echo "Approved ";
	}
	else
		die("Error");
	
	//status
	$status = mysql_query("SELECT * FROM stud WHERE s_id = '".$id."' ");
	$qry = mysql_fetch_array($status);
	
	if($qry['approve'] == '1') {
			?>
			<div class="app"> <?php
			echo "<b>".$qry['name'] ."</b>"." Approved Successfully "." <br />";
			?>
			</div>
			<?php
		}
?>
</body>
</html>
mdviky87 is offline   Reply With Quote