Don't use jquery ajax to make a network request. use the native
$network.request to make a request and render that result using templates.
There are many things wrong with using jquery ajax when using web containers. Here are just a couple:
- You're just wrapping a website in a native app if you do it this way. Might as well use phonegap.
- I haven't tried it this way (because this is not the way to go) but I'm guessing there will be cross origin issues making ajax calls anyway if you're making a ajax request to a remote server from web container.
Take a look at the examples on Jasonpedia to see how you can integrate content fetched via
$network.request (For example https://github.com/Jasonette/Jasonpedia/blob/gh-pages/webcontainer/d3graph.json)
I think a lot of people confuse what web container is for and think it's a phonegap alternative. It's not. It's a native way of integrating a web view into an app. Approaches like phonegap where you're letting the browser do all the work such as ajax calls is not native because you're now stuck with depending on the browser. Jasonette lets you take advantage of native APIs and let you use web containers as just a dumb output facet.
Basically the best way to use web containers is to think of it like any other components like label, image, etc. You're using it as a way to print things, not to do all the hard work like network requests.
Hope this makes sense.