我的结构如下所示: 谷歌浏览器扩展程序。获取JSON数据局部
我的manifest.json如下图所示:
我的index.html如下图所示:
<!DOCTYPE html>
<html>
<head>
<META http-equiv=content-type content=text/html;charset=utf8>
<META http-equiv=content-type content=text/html;charset=windows-1254>
<META http-equiv=content-type content=text/html;charset=x-mac-turkish>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src="doktormdcore.js"></script>
<title>Doktor TV Md</title>
<script type="text/javascript">
function GetDataFunction()
{
var xhr = new XMLHttpRequest();
xmlHttpRequest.onreadystatechange = handleStateChange; // Implemented elsewhere.
xmlHttpRequest.open("GET", chrome.extension.getURL('/config_resources/config.json'), true);
xmlHttpRequest.send();
}
</script>
</head>
<body>
<table>
<tr>
<td>GetData</td>
<td><input type="button" id="GetData" value="Getir" onclick="GetDataFunction"/></td>
</tr>
</table>
</body>
</html>
我的配置.json数据(示例数据)如下所示:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
我想从我的config.json中获取json数据。但是,我如何测试这段代码以确保它们正在工作。你认为我是对的吗?这是从本地获取json值的正确方法吗?
谢谢你的帮助。 – fuat