when i used jquery ajax for fetching a data from database the response text contains html codes also. my code so far is:
$("#onclick").click(function() {
$.ajax({
async:"true",
type:"POST",
url:"process.php",
dataType: "text",
data:"tempid="+tid,
success:function(dat) {
$("#templ").html(dat);
}
});
});
The file process.php contains only the below code
include "connect.php";
if(isset($_POST['tempid'])&& $_POST['tempid']>0)
{
$temp_id= $_POST['tempid'];
$sql="SELECT template FROM templates WHERE tid='".$temp_id."'";
$res= mysql_query($sql);
if((mysql_num_rows($res))>0)
{
While($row = mysql_fetch_array($res))
echo '<b>'.$row['template'].'</b>';
}
else
{
echo 'NOT';
}
}
the outptut i got is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
<b>/* The mysql value */</b>
Is there any mistakes in my code? i want to show only that mysql value in my textbox with id templ. How to avoid all that html code from response? Please tell me if any further details are required..