PhoneGap Ajax通话

Currently I am using an Ajax call to load a handlebar template from my local webserver into the application.

  $.ajax({
       url: "http://localhost/myTemplate.html",
       cache: true,
       success: function (data) {
           template = Handlebars.compile(data);
           $('#anyID').append(template);
       }
  });

Chrome on the Desktop does it fine, in contrast to my Android phone.

Is there a way to load the template correctly using PhoneGap?

Thanks a lot.

You're calling an absolute URL (http://localhost/). It works fine on your desktop, because it happens to be also your localhost, by chance.

But your phone is not your localhost. There is no web server running on your phone, so no localhost.

Use relative paths like url : "myTemplate.html"