简单jQuery AJAX XML加载不起作用
我只是尝试使用AJAX加载一些简单的XML数据,但没有效果,而且我一生都找不到错误。感谢您的帮助。代码如下: 有关网页:简单jQuery AJAX XML加载不起作用,jquery,xml,ajax,Jquery,Xml,Ajax,我只是尝试使用AJAX加载一些简单的XML数据,但没有效果,而且我一生都找不到错误。感谢您的帮助。代码如下: 有关网页: <html> <head> <title>Big Skinny Wallet Helper</title> <style> #nav { position:absolute; left:0px; width:300px; background-color:#b0e0e6; } #content
<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>
大皮夹助手
#导航
{
位置:绝对位置;
左:0px;
宽度:300px;
背景色:#b0e0e6;
}
#内容
{
位置:绝对位置;
左:300px;
}
您的XML未验证<代码>&
应为&代码>
作为将来的参考,请尝试。您实际会遇到哪些错误?请描述您的问题。检查控制台是否有任何错误该问题似乎与xml数据有关,它提供了一个解析erorCheckout ok,这是因为您使用的是本地文件系统。使用像tomcat这样的web服务器并再次检查它谢谢!这似乎已经解决了,太好了。如果正在生成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>