0

Phonegap 1.5.0 から 2.0.0 にアップデートしましたが、ダウンロードで問題が発生しました。

これが私のダウンロード機能です:

function download(){
var ecodedurl = "http://finance.yahoo.com/d/quotes.csv?s=^NSEI+^NSEBANK&f=pl1";
      var remoteFile = encodeURI(ecodedurl);
      var localFileName = "temp.txt";
      var attachmentFileName = localFileName;
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
      fileSystem.root.getDirectory("Temp", {create: true, exclusive: false}, function(directoryEntry) {
       directoryEntry.getFile(localFileName, {create: true, exclusive: false}, function(fileEntry) {
        var localPath = fileEntry.fullPath;
       if (device.platform === "Android" && localPath.indexOf("file://") === 0) {
         localPath = localPath.substring(7);
                  }
                       var ft = new FileTransfer();
                     ft.download(remoteFile,
              localPath, function(entry) {
                           attachmentFileEntry = entry;
                 loadFileData(attachmentFileEntry);
                                                                                               }, fail);
                                                                                   }, fail);
                                                            }, fail);
                               }, fail);
      function fail(error) {
          //console.log(error.code);
          //alert("Error occured while downloading the attachment");
          navigator.notification.alert('Error occured while downloading the attachment. Please try again', alertConfirm);
      }

  }

  }

function loadFileData(allText) {
    console.log("loadFileData method:"+allText);
    console.log("allText URL:"+allText.toURL());
    var fileURL = allText.toURL().substring(7);
    console.log("URL:"+fileURL);
    $.ajax({
           type: "GET",
           url: fileURL,
           dataType: "text",
           success: function(data) {
           console.log("file loaded");
           processData(data);}
           });

ファイル転送エラーの取得: ソース URL がホワイト リストにありません: http://finance.yahoo.com/d/quotes.csv?s= ^NSEI+^NSEBANK&f=pl1

phonegap.xml ファイルに含めようとしました...それはうまくいきません:(

4

1 に答える 1

0

IPhone アプリケーションの場合は、xcode の Resources の下にある Cordova.plist を編集する必要があります。それを編集します (xcode xml エディターを使用することをお勧めします。つまり、クリックするだけです)。外部ホストの下に文字列項目を追加します。値では、サイトを設定するか、外部サイトの場合は * を設定します。

于 2012-09-17T08:30:41.173 に答える