Search code examples
javascriptjquerycordovamobile-safari

jQuery $.get doesn't work for "local" files in Phonegap or Mobile Safari


I have a templating system I was trying to use with my Phonegap App that utilizes jQuery and the $.get() function.

$.get('templates/' + name + '.html', someFunctionHere(){});

When I run the app as a server on localhost and view it through Chrome or Safari the templating system works perfectly.
When I run the app through Phonegap on the iOS Simulator, it doesn't work. No file is returned and "someFunctionHere()" doesn't run.
Important note: When I use Mobile Safari under the iOS Simulator to view the page served by my localhost it also does not work.

To me, this sounds like the WebKit browser that Mobile Safari and Phonegap use won't allow access to local files? This feels completely incorrect but that's how it looks.

Has anyone encountered this problem before, or know of a way to get around it?


Solution

  • I think safari does not support async call which is on by default and you need to turn off async mode in order to get it worked in safari.