javascript - 在 PhoneGap 应用程序中从服务器远程显示图像的最佳方式是什么

标签 javascript jquery ajax cordova

我正在尝试使用phoneGap以及jquery(移动)和PHP在应用程序中显示来自远程服务器的图像。

我从文档中了解到该函数可以完成这项工作:

FileTransfer

这里:http://docs.phonegap.com/en/1.6.0/cordova_file_file.md.html

 // !! Assumes variable url contains a valid URI to a file on a server and filePath is a valid path on the device

var fileTransfer = new FileTransfer();

fileTransfer.download(
    url,
    filePath,
    function(entry) {
        console.log("download complete: " + entry.fullPath);
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("upload error code" + error.code);
    }
);

我的问题是我不知道到达应用程序根目录的文件路径应该是什么? 主要问题(这就是我创建这篇文章的原因)是我从文档中读到

It is also possible to download a file from remote and save it on the device (only iOS and Android).

这对我来说是个问题..

那么我应该做什么,我可以将服务器上的图像网址提供给我的phonegap应用程序中图像的src吗?这行得通吗?

谢谢

最佳答案

我通常使用 html 标签在 PhoneGap 应用程序中显示来自远程服务器的图像。

关于javascript - 在 PhoneGap 应用程序中从服务器远程显示图像的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17424608/

相关文章:

javascript - jquery/js 语法对象数组

php - 使用 AJAX 加载 PHP 页面是好习惯吗?

php - jQuery 不能在 AJAX 加载的 DIV 中工作

javascript - 随着框架的变化动态缩放 iFrame 内容

javascript - 事件仅在触发两次时才会触发

javascript - 为从特定 URL 进入的用户更改页面元素

javascript - Kendo UI 网格保存单元格模糊

mysql - 如何使用ajax(客户端)将数据插入到mysql表中

javascript - react rails : component does not re-render after record created

javascript - 脚本中的问号会破坏 html