How to load local html file?

Posted:
Wed Jun 25, 2014 4:52 am
by rjot
Hello,
In LG .load() from jQuery works, but in SDK Alliance emulator don't work. I'll try:
- Code: Select all
1. $( \"#dynamicContent\" ).load( \"./html/currency.html\");
2. $( \"#dynamicContent\" ).html( loadPage(\"html/currency.html\"));
function loadPage(href) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open(\"GET\", href, false);
xmlhttp.send();
return xmlhttp.responseText;
}
3. var url = './html/currency.html';
$.get(url, function(response) {
$('#dynamicContent').html(response);
})
so, how to load local html file?
How to load local html file?

Posted:
Wed Jun 25, 2014 6:29 pm
by Support_STA
Hi,
In your case, we suggest you should use absolute path instead of relative path to make sure about it.
Maybe, emulator get problem with relative path as you did.
Aside, you can check root problem by Console Tab (open by \"Inspect Element\" option in menu context -> Choose Console Tab).
Hope this help!
Regards,
STA Support
How to load local html file?

Posted:
Thu Jun 26, 2014 1:33 am
by rjot
hi, thanks for ur reply. I'll try with absolute path, but still shows the same errors: \"URL cannot be shown\", i prepare test app with this issue.
- Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
<title>Test Load</title>
<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-2.1.1.min.js\"></script>
<script type=\"text/javascript\"> [size=2][/size]
$(document).ready(function() {
var absoluteLoc = window.location.protocol + '//' + window.location.pathname;
var absolutePath = absoluteLoc.substr(0, absoluteLoc.lastIndexOf(\"/\"));
console.log(absolutePath);
$('h1').click(function() {
$( \"#dynamicContent\" ).load(\"content.html\");
$( \"#dynamicContent\" ).load( absolutePath + \"/content.html\");
$.get(absolutePath + \"/content.html\", function(response) {
$('#dynamicContent').html(response);
});
$( \"#dynamicContent\" ).html( loadPage(absolutePath + \"/content.html\"));
});
});
function loadPage(href) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open(\"GET\", href, false);
xmlhttp.send();
return xmlhttp.responseText;
}
</script>
</head>
<h1>Load content.html</h1>
<div id=\"dynamicContent\"></div>
</body>
</html>
in content.html
- Code: Select all
<h2>Yupii, u make it!!!</h2>
How to load local html file?

Posted:
Fri Jun 27, 2014 2:25 am
by supporter lead_1
Hi,
I think you open your file in offline status (just open html file and load an local html file by ajax). Not only you, but also much others can't do it.
To do same thing in offline status, you can use iframe instead of ajax load.
Regards,
STA Support