我收到这个消息
未捕获异常对象#displayusersearch2没有方法"html"
代码为:
<script src="../../javascript/jqueryfunctions.js" type="text/javascript"></script>
<script src="../../jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function uid_id_search_change()
{
var search=document.getElementById('uid_id_search').value;
$.get('userdisplaypopup.php?id='+search,userset);
}
function userset(res)
{
('#displayusersearch2').html(res);
Uncaught TypeError: Object #displayusersearch2 has no method 'html'
}
</script>
<table width="600" border="0">
<tr>
<th scope="row"><font size="-1">Book Id</font></th>
<td><input type="text" value="1" id="bid_popup" /></td>
</tr>
<tr>
<th scope="row"><font size="-1">Book Name</font></th>
<td><input type="text" value="1" /></td>
</tr>
<tr>
<th scope="row"><font size="-1">Author</font></th>
<td><input type="text" value="1" /></td>
</tr>
<tr>
<th scope="row"><font size="-1">Publisher</font></th>
<td><input type="text" value="1" /></td>
</tr>
<tr>
<th scope="row">Search User</th>
<td><input type="text" id="uid_id_search" name="uid_id_search" onkeyup="uid_id_search_change();" />
<div id="displayusersearch2"></div></td>
</tr>
</table>
div的id是displayusersearch2
。请求发送正确。我正在尝试将响应显示在div displayusersearch2
上。
('#displayusersearch2')
您省略了使其成为jQuery包装调用的$
。如果没有它,这只不过是一个字符串文字。字符串'#displayusersearch2'
没有html()
方法。
$('#displayusersearch2').html(res);
此外,
$.get('userdisplaypopup.php?id='+search,userset);
对于任何包含URL特殊字符的search
术语,都将失败。建议使用encodeURIComponent()
,或者让jQuery为您完成:
$.get('userdisplaypopup.php', {id: search}, userset);