xml2json jQuery插件不起作用 [英] xml2json jQuery plugin not working
本文介绍了xml2json jQuery插件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Fyneworks.com的 jQuery XML to JSON插件.
I'm using the jQuery XML to JSON Plugin by Fyneworks.com.
为什么此代码不起作用?
Why this code isn't working?
index.html
<!DOCTYPE html>
<html>
<head>
<script src="build/jquery.xml2json.js"></script>
<script src="build/jquery.js"></script>
<script>
$(document).ready(function() {
$('button').click(function() {
$.get('menu.xml', function(xml){
var json = $.xml2json(xml);
alert(json.message);
});
});
});
</script>
</head>
<body>
<button>Menu List</button>
</body>
</html>
menu.xml
<xml>
<message>Hello world</message>
</xml>
错误是:未捕获的TypeError:$ .xml2json不是函数
the error is : Uncaught TypeError: $.xml2json is not a function
推荐答案
jquery.xml2json.js
取决于jquery
.因此,我们必须先加载jquery.js
,然后再加载jquery.xml2json.js
.
jquery.xml2json.js
depends on jquery
. So we have to load jquery.js
first, and then jquery.xml2json.js
.
<script src="build/jquery.js"></script>
<script src="build/jquery.xml2json.js"></script>
这篇关于xml2json jQuery插件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文