I'm developing a mobile app which will be used with phonegap. I am testing the app in a browser by loading from the file system with file:///<path-to-app>
I have the following in <head>:
- <script type="text/javascript" charset="utf-8" src="javascripts/jquery.min.js"></script>
- <script type="text/javascript" charset="utf-8">
- $( document ).bind( "mobileinit", function() {
- $.support.cors = true;
- $.mobile.allowCrossDomainPages = true;
- $.mobile.pushStateEnabled = false;
- });
- </script>
- <script type="text/javascript" charset="utf-8" src="javascripts/jquery-mobile-1.0.js"></script>
My understanding is that $.support.cors and $.mobile.allowCrossDomainPages being set to true should allow me to complete ajax json requests successfully. Can anyone confirm this or tell me what I might be doing wrong?
I was using jsonp until I discovered these settings and was hoping they would allow me to use json instead. My ajax call looks something like this:
- var ajax_url = <someResource.json>;
- var ajax_data = <someParams>;
- var auth_token = <authTokenFromRails>;
- $.ajax({
- type: 'POST,
- dataType: "json",
- crossDomain: true,
- url: "http://localhost:3000/" + ajax_url,
- cache: false,
- data: 'auth_token=' + auth_token + '&' + ajax_data,
- });
I haven't tried in phonegap yet, I would just like to make it work with a file:/// url first.