我正在尝试制作一个获取图像并将其存储到我的设备的网络应用程序。然后它需要使用图片作为另一个页面的链接。
如果我在我的本地机器(网络服务)上尝试它,我会成功。但是当我把 i 放到我的域中(相同的代码+使用高级休息客户端测试)时,它失败了。
我尝试制作一个 appcache 文件,并在 NETWORK 下写入 * 或我的域名:
这是我的 httprequest ( javascript ) 代码:
var startUrl = "http://localhost:8080";
function getStuff(theUrl){
startUrl = "http://mobilitycms.lector.dk:9090";
alert(startUrl+theUrl);
$(document).ready(function() {
$.ajax({
url: startUrl+theUrl,
type: 'GET',
dataType: 'json',
success: function(data) {
alert('success');
createMainMenu(data);
alert('new cursor created:' + cursor);
/* $.each(data.list, function(i, object) {
alert(i+"="+object);
var array = new Array();
for (property in object) {
var value = object[property];
alert(property + "=" + value);
}
});*/
},
error: function() {
alert('boo!');
},
beforeSend: setHeader
});
});
}
function setHeader(xhr) {
xhr.setRequestHeader('app', '1');
}
html
<div data-role="header">
<a href="#" data-rel="back" data-role="button" ><img align="middle"src="images/back.png" alt="beskeder" vspace="2"/></a>
<h1><img onclick="getStuff('/product/5')" align="middle"src="images/main_header.png" alt="beskeder" vspace="2"/></h1>
</div><!-- /header -->
<div data-role="content" id="firstPageContent">
<p>I'm first in the source order so I'm shown as the page.</p>
<p>View internal page called <a href="#second">second</a></p>
<a href="#second" id="mapLink" name="mapLink"><img id="mapLinkImage" alt="a map which links to the mapPage" src="images/beskeder.png"/></a>
<Button id="loadButton" onClick="load()"/>
</div><!-- /content -->
</div><!-- /page -->
为什么会失败?
附言。如果有人对这种“webapp”有一些好的指南/模式,那么它也是最受欢迎的,因为我是这个 js/webapp 开发的新手。
我当前的 RAW(高级休息客户端)响应:
{"data":null,"server":null,"list":[{"name":"Herre Briller","parent":-1,"id":1,"fileName":"men","childrenType":"GROUPS","sortOrder":0,"picture":"/content/picture/products/men","grCount":3,"prCount":0},{"name":"Dame Briller","parent":-1,"id":2,"fileName":"women","childrenType":"GROUPS","sortOrder":1,"picture":"/content/picture/products/women","grCount":3,"prCount":0},{"name":"Børne briller","parent":-1,"id":3,"fileName":"children","childrenType":"GROUPS","sortOrder":2,"picture":"/content/picture/products/children","grCount":1,"prCount":0}],"expires":7200000}