Goal:
When click_div is clicked, the script should read a file (text.html) from my own computer using $.get() method, and set the html of a div (cont_div) to the file's content.
Code:
$(document).ready(function() {
$('#click_div').click(function(){
var HTML_FILE_URL = 'text.html';
$.get(HTML_FILE_URL, function(data){
alert(data);
$('#cont_div').html(text);
});
});
});
Problem:
The content of cont_div keeps blank, after clicking click_div. I put an alert to show the content of what the get method read, and it displays a blank dialog.
Further information:
• The file is on the same folder as the .js file, and the index.html page file.
• All the other javascript functions work well.
Question:
Given that the alert function displays nothing, but is still called, what could I possibly be doing wrong? I've tried many things, but it really doesn't work.