Version: JQM 1.4.5.
Scenario
When server side is sending back invalid markup instead of expected json data for ajax call, UI end would display whatever the server end is sending back (e.g. Sign in page, system error page...)
It has been working out well for desktop version for a long time. Now I am trying to port the logic to work for JQM, I am having trouble.
Symptoms:
(a) page mark up is not enhanced. (b) Style sheet (that is specified in the tag within the redirected html page) is not applied
Code:
$.ajax({
type: "POST",
dataType: "json",
...
error: function (XMLHttpRequest, textStatus, errorThrown) {
...
//display whatever server sends back.
if (textStatus == parsererror_textStatus ) {
document.write(XMLHttpRequest.responseText);
$('#main').trigger('pagecreate');
$('#main').enhanceWithin();
}
}
});
References
I have searched quite a bit over the web. But it has not worked out for me yet. Any suggestions?
https://www.gajotres.net/jquery-mobile-and-how-to-enhance-the-markup-of-dynamically-added-content/
jquery mobile Dynamically Injecting Pages
http://demos.jquerymobile.com/1.3.2/faq/scripts-and-styles-not-loading.html
jQuery Mobile does not apply styles after dynamically adding content
Forcing jQuery Mobile to re-evaluate styles/theme on dynamically inserted content