0

I have an application made by using phonegap 1.5.0 and jquery mobile 1.1.0.... I have a structure like this

<div data-role="page" id="page1">       
</div>

<div data-role="page" id="page2">       
</div>

I call a webservice on page show of the page2 like this

$("#page2").on("pageshow", function(e) {
$
    .ajax({
        type : 'GET',
        url : "http://192.168.1.88:9051/some.xml"
                + "?time=" + Date.now(),
        data : {
            key : "value"
        },
        dataType : "xml",
        success : function(xml) {

        },

        error : function(xhr) {
            alert("Error while loading the Mock Service !!!");
        }
    });
});

This works fine if i enter for the first time to Page2. Suppose if i navigate back to page1 and then again to Page2 then the webservice isnt called.

I even tried with pageinit and it didnt worked... Is this some Ajax issue?

How to rectify this?

coderslay
  • 13,960
  • 31
  • 73
  • 121
  • http://stackoverflow.com/questions/5622581/jquery-mobile-document-ready-equivalent asks to use pagebeforeshow. – ganeshran Apr 02 '12 at 06:44

2 Answers2

2

Have you tried turning off caching?

// setup globally
$.ajaxSetup ({
    cache: false
});

Or,

// setup individual calls
$.ajax({
    cache: false, // disable caching
    type : 'GET',
    url : "http://192.168.1.88:9051/some.xml"
            + "?time=" + Date.now(),
    data : { key : "value"},
    dataType : "xml",
    success : function(xml) {

    },

    error : function(xhr) {
        alert("Error while loading the Mock Service !!!");
        }
    });
});
Dennis Rongo
  • 4,611
  • 1
  • 25
  • 25
0

did you check with firebug, the "Console" and the "Net" tab to see what your script sends and receives?

$("#div")

looks wrong to me. should be either div (all div elemets) or #page1 (id 'page1')

iHaveacomputer
  • 1,427
  • 4
  • 14
  • 30