PhoneGap Relative URL

后端 未结 3 1219
花落未央
花落未央 2021-01-13 04:16

I\'ve build a mobile site using jQTouch, and now I\'ve been working to get that same site working with PhoneGap. For PhoneGap, I\'ve moved most all of the assets (pages, im

3条回答
  •  终归单人心
    2021-01-13 05:01

    I know this is 6/7 years old, but for any others arriving here for the same question... Here's a solution, since there isn't a more "packaged" one:

    3 quick steps:

    1) Store your site domain in a global javascript variable

    var currentloc = 'https://example.com'
    

    2) Use temporary variable to add your relative path to currentloc

    var relpath = '/need/jsonex'
    var ajaxcall = currentloc + relpath
    $.ajax({...
    

    3) Adjust currentloc if you do change the supposed "location" that you're calling relative path from on site

    currentloc = currentloc + '/new/path'
    

    ** just remember if you make currentloc a global variable you need to keep track of these changes.

    Hope this helps.

提交回复
热议问题