1

I am on developing cross platform phonegap application.Here i am loading a webpage which is hosted in server. i have done it by changing my loadUrl("...*/server/index.html");

Then I want to know is there any way to load required css/image files from assets folder on phonegap.Like what we are doing when all files are reside in www folder of phonegap.

I have tried this but it got error, local resource cannot be accessible. And I am asking is there any possible way to do so???

I am once more mentioning that i am trying for a cross platform application.

Thanks in advance for your valuable reply...

sreejin
  • 81
  • 2

1 Answers1

0

So what I understand from your question is:

  1. you access a html page from server

  2. you want that page to use local resources such as image.

So answer to this question is simply No, you cant do it.


but yes, you can change your approach a little bit, and still download html from server and use local images from assets.

let the page be on the app itself, and just load the html from the server using ajax.

Steps:

1) index.html will reside within the app

2) download html from server using ajax call ex:

$(function () {
    $.ajax({
        url: "yourserver.com/getHtml",
        dataType: "html", // set the datatype to html
        success: function (data) {
            // append the data here to page
        }

    });
});

Now, that you have loaded the html for the page from server, still your page is local So you are now able to load local assets like images into your webpage like you normally do from www folder.

Community
  • 1
  • 1
Naeem Shaikh
  • 15,331
  • 6
  • 50
  • 88