I have a phonegap application running on the Jquery Mobile framework. I have a number of combo boxes (selects) which fire an ajax query on change. The code works fine when using native menus however when I switch to data-native-menu="false" the code fails to perform a callback, this happens on my android device and not on an emulator or browser. I can't get my device to work in debug mode for some reason.
The code reaches the on change event, it gets to the beforeSend function in $.ajax but it never completes/errors. I have even tried adding a hidden field and usig that to fire the event so it's definitely on the correct page and not stuck on the popup.
I'll try and make a jsfiddle.
$(document).delegate('#p1', 'pageshow', function () {
$("#aS").change(function(){
alert('going to change');
getAjax('',{},function(){
alert('got callback');
});
});
});
function getAjax(request,datain,callback){
$.mobile.showPageLoadingMsg();
$.ajax({
type: "GET",
url: 'http://open.live.bbc.co.uk/wurfldemi/network.jsonp?callback=?'+request,
// async: false,
data: datain,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
dataType: "jsonp",
success: function(data){
$.mobile.hidePageLoadingMsg();
callback(data);
},
error: function (xhr, ajaxOptions, thrownError) {
$.mobile.hidePageLoadingMsg();
alert(xhr.status);
alert(thrownError);
}
});
return false;
}
edit
Just to reiterate, this is not a problem (as far as I can see) with adding an event handler to the on change event of the select but with either the request it's self or the callback.
The page works fine when using data-native-menu="true". I only used '$(document).ready(function(){' in fiddle as I did not know how to get it to work any other way, I do not use this in the real app.
edit I've tried this on 5 devices, it seems to work on 4.2, 4.1, 2.5 but not on 3.