I'm building a mobile web application that may or may not rely on ajax, depending on whether the user's browser supports javascript. Since I'm using JQuery, I want to make sure the mobile browser supports AJAX through JQuery before enabling my AJAX functionality.
I'm running into a problem with Opera Mini because of the way it renders pages, and I'm not sure how to check it. Here's the code I'm using to test for AJAX:
$(document).ready(function () {
$.get(
'test.txt',
function() {
init_ajax();
}
);
});
Where init_ajax() enables my ajax functionality and disables my static functionality.
The problem is, Opera Mini runs this code successfully before outputting the page to the browser, but then ajax does not actually work on the rendered page. I tried running this function in a setTimeout instead of on document.ready, but encountered the same problem.
Is there a universal way to accurately test for the presence of AJAX in mobile browsers?
P.S. If you want to test your solution in Opera Mini, there's a fully functional emulator here:
http://www.opera.com/mini/demo/
[Edit] I should mention that this application needs to make an ajax call approximately once per minute using setInterval, so even though Opera Mini does support some ajax when it is triggered by an onclick, I don't believe there's any way to make it support ajax calls made at a certain interval. If we could test for this, that would likely solve the problem above.