[英]PhoneGap load local page inside HTML
I tried to load a page inside my phonegape aplication with Jquery .load()
but it doesn't work since it's not on a server and it's on local machine. 我试图用Jquery .load
.load()
在我的phonegape应用程序中加载一个页面,但是它不起作用,因为它不在服务器上,而且在本地计算机上。 When I'll upload the app on build. 在构建时上传应用程序的时间。 phonegape my page will still be included on the
www
folder. phonegape我的页面仍将包含在
www
文件夹中。 How can I load a page inside a div ? 如何在div内加载页面? This is not working
这不行
<script>
$(".form-control2").change(function(){
$(".plan_mese4").load("select_mese.html");
});
</script>
If I use http
it's working but i don't need that since my file is local and not on a server. 如果我使用
http
它可以工作,但是我不需要,因为我的文件是本地文件,而不是在服务器上。
edit* 编辑*
Right now i have my app on desktop, i also compiled it with phonegap and .load() it's not working since the file is local. 现在我将我的应用程序放在桌面上,我也使用phonegap和.load()对其进行了编译,因为该文件是本地文件,因此无法正常工作。 It only works if i put my file on a server and i load it from there but i don't want that since the request take more time.
仅当我将文件放在服务器上并从那里加载文件时,它才起作用,但我不希望这样,因为请求需要更多时间。
thnx to Quentin i found that i can use the filepath to make an ajax call even if it's local. thnx到Quentin我发现我可以使用文件路径进行ajax调用,即使它是本地的也是如此。 So i did it like this if anyone else needs it.
因此,如果有人需要它,我会这样做。 I get the url location in my case
file:///E:/rezerv.city/www/local.html?id=114&tip=5
and i remove the local.html?id=114&tip=5.html
part and i add what i need in my case select_mese.html. 我在我的案例
file:///E:/rezerv.city/www/local.html?id=114&tip=5
获得了网址位置file:///E:/rezerv.city/www/local.html?id=114&tip=5
并且我删除了local.html?id=114&tip=5.html
部分,我添加了我需要的是select_mese.html。
$(".form-control2").change(function(){
var url =window.location.href;
url = url.substring(0, url.lastIndexOf("/") + 1);
$(".plan_mese4").load(url +'index.html');
});
in my app I'm use: 在我的应用中,我正在使用:
<div id="loadExternalURL" class="site"></div>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$('#loadExternalURL').load('http://www.site.com.br');
$.ajax({
dataType:'html',
url:'http://www.site.com.br',
success:function(data) {
$('#ajax').html($(data).children());
}
});
}
It works for me. 这个对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.