I have been struggling with this for quite some time now. jQuery.ajax in the code below never runs. I know that is because I'm using the wrong pageinit/document.ready.
One other strange thing is that the pageLoadingMsg doesn't become "Laddar..." as specified below, but "loading"...
I have tried to initialize the ajax call with:
But what should I use? I have tried:
$(function() {
$(document).live( 'pageinit',function(event){
$(document).live( 'pagecreate',function(event){
$(document).bind( 'mobileinit',function(event){
$(document).bind( 'pageinit',function(event){
My complete code:
$(function() {
var photos = {};
$.mobile.showPageLoadingMsg("Laddar...");
$.ajax({
type: "get",
url: "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
data: ({tags: 'cat', format: 'json', tagmode: 'any'}),
cache: false,
dataType: "json",
success: onSuccess,
error: onError
});
});
//////////////////////////////////////////////////////////////////////////
//
// Handle the returned data
//
//////////////////////////////////////////////////////////////////////////
function onSuccess(data)
{
photos = data;
var output = [];
for (var i = 0, len = data.items.length; i < len; i++) {
output.push('<li><a data-index="' + i + '" href="details.html?author='+ data.items[i].author +'&image='+ data.items[i].media.m +'"><img src="images/de.png" class="ui-li-icon">' + data.items[i].author + '</a></li>')
};
$('#list').append(output.join('')).listview('refresh');
$.mobile.hidePageLoadingMsg();
}
//////////////////////////////////////////////////////////////////////////
//
// Failure for the ajax call
//
//////////////////////////////////////////////////////////////////////////
function onError(param1, param2, param3)
{
alert(param1); alert(param2); alert(param3);
}