I have a json file with some data to append into a div in the html document when a button is clicked:
html:
<div class="json"></div>
<button id="one"></button>
here the javascript:
function one(){
$("#one").click(function(){
$.getJSON('one.json',function(data){
alert("success");
})
.done(function() { alert('getJSON request succeeded!'); })
.fail(function() { alert('getJSON request failed! '); })
.always(function() { alert('getJSON request ended!'); });
});
}
$(document).ready(function() {
one();
});
the one.json file is in the same directory of js file. When I click the button the alert is "getJSON request failed"...where is the mistake?