weixin_33749131 2015-05-07 12:10 采纳率: 0%
浏览 43

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.

  • 写回答

1条回答 默认 最新

  • weixin_33674976 2015-05-07 12:33
    关注

    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"

    评论

报告相同问题?