<!DOCTYPE html>
<html>
<head>
<title>JSONTest</title>
<script src="js/jquery-1.9.1.min.js"></script>
<script type=text/javascript>
$(document).ready( function() {
$("input:button").click(function(){
$.ajax({
type: "GET",
url: "test2.php",
//JSON typeでは読み込めなかったためtxtとして読み込む
//dataType:"json",
success: function(msg) {
console.log(msg);
//ここでtxtをJSONに変換しようとしてエラー ・
console.log(eval(msg));
},
false: (function(jqXHR, textStatus, errorThrown) {
console.log("Error: " + textStatus);
console.log("Test: " + jqXHR.responseText);
})
});
});
});
</script>
</head>
<body>>
<input type="button" value="testButton" />
</body>
</html>
PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KICAgIDx0aXRsZT5KU09OVGVzdDwvdGl0bGU+CiAgICA8c2NyaXB0IHNyYz0ianMvanF1ZXJ5LTEuOS4xLm1pbi5qcyI+PC9zY3JpcHQ+CiAgICA8c2NyaXB0IHR5cGU9dGV4dC9qYXZhc2NyaXB0PgogICAgICAgICQoZG9jdW1lbnQpLnJlYWR5KCBmdW5jdGlvbigpIHsKICAgICAgICAgICAgJCgiaW5wdXQ6YnV0dG9uIikuY2xpY2soZnVuY3Rpb24oKXsKICAgICAgICAgICAgICAgICQuYWpheCh7CiAgICAgICAgICAgICAgICAgICAgdHlwZTogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgdXJsOiAidGVzdDIucGhwIiwKICAgICAgICAgICAgICAgICAgICAvL0pTT04gdHlwZeOBp+OBr+iqreOBv+i+vOOCgeOBquOBi+OBo+OBn+OBn+OCgXR4dOOBqOOBl+OBpuiqreOBv+i+vOOCgAogICAgICAgICAgICAgICAgICAgIC8vZGF0YVR5cGU6Impzb24iLAogICAgICAgICAgICAgICAgICAgIHN1Y2Nlc3M6IGZ1bmN0aW9uKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICAvL+OBk+OBk+OBp3R4dOOCkkpTT07jgavlpInmj5vjgZfjgojjgYbjgajjgZfjgabjgqjjg6njg7wgICAgICAgICAgICAgICAgIOODuwogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhldmFsKG1zZykpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgZmFsc2U6IChmdW5jdGlvbihqcVhIUiwgdGV4dFN0YXR1cywgZXJyb3JUaHJvd24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkVycm9yOiAiICsgdGV4dFN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJUZXN0OiAiICsganFYSFIucmVzcG9uc2VUZXh0KTsKICAgICAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgfSk7CgogICAgPC9zY3JpcHQ+CjwvaGVhZD4KCjxib2R5Pj4KPGlucHV0IHR5cGU9ImJ1dHRvbiIgdmFsdWU9InRlc3RCdXR0b24iIC8+CjwvYm9keT4KPC9odG1sPg==