我是JS,AJAx的初学者,等等。我在互联网上搜索并发现了一个代码,所以我用它,稍微改了一下......但似乎它没有用(它什么也没做)。 首先是javascript和html:
function fetch_select(val)
{
$.ajax({
type: 'post',
url: 'fetch_data.php',
data: {
get_option:val
},
success: function (response) {
document.getElementById("new_select").innerHTML=response;
}
});
}

<select onchange="fetch_select(this.value);">
<option>Wybierz</option>';
$zapytanie = "
SELECT
scan_category.scat_id,
scan_category.long_name
FROM
scan_category
WHERE
scan_category.state = 1 OR scan_category.state = 4 and scan_category.hide = 0
ORDER BY
scan_category.long_name";
$wykonaj = mysql_query($zapytanie) or die(mysql_error());
while($row=mysql_fetch_array($wykonaj))
{
echo '<option>'.$row[1].'</option>';
}
echo'</select>
<div id="new_select">
</div>';
&#13;
$manga = $_POST['get_option'];
$znajdz = "
SELECT users.nick, scan_category.long_name, scan_work.work_name, scan_roles.role_id, scan_roles.scat_id, scan_roles.uid, scan_roles.what_id
FROM scan_roles
INNER JOIN scan_work ON scan_roles.what_id = scan_work.work_id
INNER JOIN users ON scan_roles.uid = users.uid
INNER JOIN scan_category ON scan_category.scat_id = scan_roles.scat_id
WHERE
scan_roles.scat_id = '$manga'";
$wykonaj = mysql_query($znajdz or die(mysql_error());
while ($row = mysql_fetch_array($znajdz)) {
echo '<h2>'.$row[1].
'</h2><br />'.$row[2].
':
<form enctype="multipart/form-data" action="manage.php5?mode=edit_role&edit&role_id="'.$row[4].
' method="POST">
<input type="hidden" name="pass" value="'.$_POST['pass'].
'">';
echo('<select name="user_id" size="1">');
$zapytanie = '
SELECT
users.uid,
users.nick
FROM
users
WHERE
active > 0
ORDER BY
users.nick';
$wykonaj2 = mysql_query($zapytanie) or die(mysql_error());
while ($wiersz = mysql_fetch_array($wykonaj)) {
echo('<option value="'.$wiersz[0].
'"');
if ($wiersz[0] == $row[6]) echo ' selected="selected"';
echo('>'.$wiersz[1].
'</option>');
}
echo '</select>';
echo('<input type="submit" value="edit">
</form>');
你知道如何让它发挥作用(它似乎甚至不会去文件&#34; fetch_data.php)。
如果我要添加其他内容,请告诉我,我几乎是初学者!
当我输入console.log(响应)时,它确实说ReferenceError:响应没有定义,当我把它打成这样 - console.log(&#34;响应&#34;)它给了我&#34;响应& #34;