我的结构如下图所示:
我的 manifest.json 如下所示:
{
"manifest_version": 2,
"name": "Doktor-MD",
"description": "Tarayıcı üzerinden Doktor-MD'de link paylaşımı yapabilirsiniz.",
"version": "1.0",
"permissions": [
"http://www.google.com/"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "index.html"
}
}
我的 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>
我的 config.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 值的正确方法吗?