开发者

jQuery AJAX will not load inside <select>

开发者 https://www.devze.com 2023-03-06 10:27 出处:网络
<html> <head> <script type=\"text/javascript\" src=\"jquery.js\"></script> <script type=\"text/javascript\">
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
   $(".region").load('getRecords.php?start=regions');

});
</script>
</head>
<body>


<select>

            <div class="region"></div>          

</select>

</body>
</html>

Whenever I put this list inside the <select> tags, it is totall开发者_StackOverflowy not displaying... When I take it outside the <select> tags I get...

    <option value="Central Asia">Central Asia</option>
    <option value="Central Europe">Central Europe</option>
    <option value="East Africa">East Africa</option>
    <option value="East Asia">East Asia</option>

Anybody have this problem? I can't find a solution to it anywhere.

This function works fine with this XMLHttpRequest function I made, but I found out today when some lady at work was trying to register with Internet Explorer, that it doesn't work with it. Blegh. So, I am making the switch to jQuery, and it burns.


select elements cannot have div elements as children. They can only have option and optgroup elements as children (see HTML specification). What happens when you put a div inside a select (and particularly when you give the div option elements as children) is up to the browser.

Try loading them into the select instead: give that element the class instead:

<select class="region"></select>


You can't have a <div> inside a <select>. Just put the class on the <select>.

<select class="region"></select>
0

精彩评论

暂无评论...
验证码 换一张
取 消