доброго времени суток, я начинаю изучат аякс вот кот index.php
<?php
include "auth.php";//Подключаем БД
//делаем запрос на категории
$query = "select * from products ";
$result = mysql_query($query) or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; Charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<form id="myForm">
product:<br/>
<select id="id">
<option selected disabled>products</option>
<?php
while ($row=mysql_fetch_array($result))
{
print "<option value=".$row['id'].">";
print $row['name'];
echo("</option>");
}
?>
</select>
</form>
<iframe frameborder="1" width= "200" height="200" scrolling="Auto" src="show.php" name="show"> </iframe>
<div id="content"></div>
<script>
$(document).ready(function(){
$("#id").change(function(){
$.ajax({
type: "get",
url: "show.php",
data: "id="+$("#id").val(),
success: function(html){
$("#content").html(html);
}
});
return false;
});
});
</script>
</body>
</html>
show.php:
<?php
include "auth.php";
$query = "select * from products where id=".$_REQUEST['id']."";
$result = mysql_query($query) or die(mysql_error());
while ($row=mysql_fetch_array($result))
{
print $row['name']."-".$row['izm']. "-" .$row['price'];
}
?>
этот код работает, но мне хотелось бы ответ вывести во фрейме:
и вместо
$("#content").html(html); (index.php, 42- строка)
пишу
window.top.frames['show'].document.location.href= "show.php";
но выдает ошибку :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
что не правильно?