我只是尝试使用AJAX加载一些简单的XML数据,但它没有任何效果,我不能为我的生活找到错误。任何帮助表示赞赏。这是代码:
对于页面:
<html>
<head>
<title>Big Skinny Wallet Helper</title>
<style>
#nav
{
position:absolute;
left:0px;
width:300px;
background-color:#b0e0e6;
}
#content
{
position:absolute;
left: 300px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script
</head>
<body>
<div id="nav">
This is text on the left.
<form>
<input type="radio" name="gender" class="gender" id="male" value="male">Male<br />
<input type="radio" name="gender" class="gender" id="female" value="female">Female<br />
</form>
</div>
<div id="content">
This is the main content area.
</div>
<div>
</div>
<script>
$(document).ready(function() {
$.get('wallets.xml', function(data) {
$('#content').empty();
$(data).find('wallet').each(function() {
var $wallet = $(this);
var html = '<div class="wallet">';
html += '<h3 class="name">' + $wallet.attr('name');
html += '</h3>';
html += '</div>';
$('#content').append($(html));
});
});
});
</script>
</body>
</html>
对于XML:
<?xml version="1.0" encoding="UTF-8"?>
<wallets>
<wallet name="Compact Sport" material="nylon" gender="male">
<description>
This is the latest bi-fold wallet in our series of super thin and light sport wallets featuring four card pockets. Since most people only use 4-6 cards regularly, just use the front two pockets for those cards and stack & store all those other cards in the hidden 2 storage pockets--go minimalist by keeping your material layers to a minimum. The favorite thin wallet used every single day by the Big Skinny founder.
</description>
</wallet>
<wallet name="Curve" material="nylon" gender="male">
<description>
Front pocket wallet-carriers, this is the model for you! We hate the state the obvious, but hey, it's fun: the curve is designed with two-rounded edges to fit neatly in your front or back pants pocket. Crafted from tough, machine-washable, nylon micro-fiber, this ultra thin wallet can hold about 20 plastic cards and cash. The pockets and billfold area are lined with a rubbery coating to help prevent your goods from sliding out: smart!
</description>
</wallet>
</wallets>