일부 JSON 코드 분석 방법 :나는이 JSON 코드 샘플 분석하고자
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
<title>Your New Application</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0, minimum-scale=1.0, user-scalable=0" />
<style type="text/css">
/* Prevent copy paste for all elements except text fields */
* { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
input, textarea { -webkit-user-select:text; }
body { background-color:white; color:black }
</style>
<script src='intelxdk.js'></script>
<script type="text/javascript">
/* This code is used to run as soon as Intel activates */
var onDeviceReady=function(){
//hide splash screen
intel.xdk.device.hideSplashScreen();
};
document.addEventListener("intel.xdk.device.ready",onDeviceReady,false);
</script>
</head>
<body>
<a href="pays.json" target="_blank">Open JSON file</a><br />
<input type="button" value="Get and parse JSON" class="button" />
<br />
<span id="results"></span>
<script src="libs/jquery-1.10.1.js"></script>
<script>
//When DOM loaded we attach click event to button
$(document).ready(function() {
//after button is clicked we download the data
$('.button').click(function(){
//start ajax request
$.ajax({
url: "pays.json",
//force to handle it as text
dataType: "text",
success: function(data) {
//data downloaded so we call parseJSON function
//and pass downloaded data
var json = $.parseJSON(data);
//now json variable contains data in json format
//let's display a few items
$('#results').html('Plugin name: ' + json.licenses[0].id + '<br />Author: ' + json.licenses[0].value);
}
});
});
});
</script>
</body>
</html>
PS : 나는 jQuery 플러그인을 사용하여 수행하는이 HTML 웹 페이지를
{
"licenses": [
{
"id": "TN",
"value": "ar"
},
{"id": "FR", "value": "fr"} ,
{"id": "GB", "value": "en"} ,
{"id": "US", "value": "en"}
]
}
을 JSON 파일은 HTML 웹 페이지와 같은 폴더에 있습니다. 문제는 "JSON 가져 오기 및 파싱"버튼을 누르면 아무 것도 표시되지 않습니다.
하여 Ajax 요청이 실행됩니다 있는지 확인하기 위해 불을 지르고 또는 유사한을 사용하여 시도하고 길을 따라 일종의 오류가있는 경우. – Cyclonecode
'텍스트로 처리 할 수있는 힘 '. 왜? – dfsq
JS 오류가 무엇입니까? 또한 코드의 많은 문제 : 1. jQuery와 전통적인 자바 스크립트를 혼합하여 사용합니다. 대신''을 사용하십시오; 3. CSS에서'*'를 사용하지 마십시오; 4. 작은 따옴표와 큰 따옴표 사용하기 – Raptor