I am using jqMobi ( NOT jQuery Mobile ) and I would like to be able to dynamically load a panel with some remote html page and then navigate to it. I have read the documentation that shows how to add a new panel with html in it, but what I'd like to do is something like this:
$.ui.addContentDiv("newDiv","somePage.html","Some Title");
I know that I could do something like this:
$.get("somePage.html",function(data){
$.ui.addContentDiv("newDiv",data,"Some Title");
$.ui.loadContent("newDiv", false, false, "up");
});
But I'm wondering if there is something better out there. Also, the above method does nothing if there is a failure, so any suggestions that you may have about that would be appreciated. As far as I can tell, there is no failure
callback for the get
method
There is an easier way - just link to the HTML page and it handles the xhr request for you. data-persist-ajax caches it in the dom, so future request do not load it.
<a href="somePage.html" data-persist-ajax="true">My Page</a>