12 Replies Latest reply on Mar 16, 2013 2:19 AM by John Michael Vincent Rustia

    Cross-domain issue using JS API in native App (no erb's)




      We are having a hard time porting our pure HTLM5 app to Rhomobile. Our goal is to port a working app using little or no ruby code. This time we are struggling with Ajax calls. Here's what we did:


      • Created a new Rhomobile project using Rhoelements capabilities.
      • Included rho-javascript in the build.yml extensions.
      • Copied our *.html, *.css, *.js files in the corresponding folders in public.
      • Imported rho-javascript in our html views using  <script src="js/rho_javascript_api.js"></script>
      • Replaced the start_path of rhoconfig.txt with start_path = '/public/index.html'
      • Debugged the resulting Rhomobile application using the RhoSimulator
      • Executed a function that depends on an Ajax call and got the following message:


      We use jQuery Ajax calls:


                  url: url, 
                  dataType: 'json',
                  data: null,
                  success: function (data, textStatus, jqXHR(){...}


      It seems like we are running into a cross-domain issue. I guess the file that was specified in the start_path is not served by the web server.


      ¿Are there any workarounds? I've read about serving the entry view using WebView.navigate, but I'm not sure how/when/where to do it.