I'm trying to get the div with the id black to echo out my JSON data, but it won't work.
So far I've done this, but it misses the timing or perhaps the logic is not right.
I have checked the JSON and it's correctly formatted.
<script>
countPos = 0;
//get JSON from school.php
$(document).ready(function(){
$.getJSON('school.php', function(data) {
window.console && console.log(data);
window.console && console.log('Document ready called');
//if button with id addPos clicked, bring up function
$('#addPos').click(function(event){
event.preventDefault();
if ( countPos >= 9 ) {
alert("Maximum of nine position entries exceeded");
return;
}
countPos++;
window.console && console.log("Adding position "+countPos);
$('#position_fields').append(
'<div id="position'+countPos+'"><br><br >\
<label for="year">Year:</label> <input type="text" size="80" name="year'+countPos+'" value="" /> \
<input type="button" value="-" onclick="$(\'#position'+countPos+'\').remove();return false;"></p> \
<label for="edu_school">School:</label> <input type="text" size="80" name="edu_school'+countPos+'" id="Autoschool'+countPos+'" value="" /><br>\
<label for="position">Position:</label> <input type="text" size="80" name="posiition'+countPos+'" value="" /><br>\
</div>\
<div id = "black"></div>')})
$ ('#black').html(data);
});
});
});
</script>