Although the answer is already given by Arun P Johny, But I just wanted to make it more clear, the proper usage of $.get()
method in jQuery
According to http://api.jquery.com/jQuery.get/#jQuery-get1 The $.get()
method is actually
jQuery.get( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] )
Where The two blocks i.e. data
and success
will only called when the request is completed, so you can call this function $.mobile.changePage("#homePage");
in either of the block
i.e. in the function (data) { }
block, like Arun P Johny suggested or you can call it in any of the other callbacks below.
var jqxhr = $.get("example.php", function() {
alert("success");
})
.done(function() { alert("second success"); })
.fail(function() { alert("error"); })
.always(function() { alert("finished"); });
Like $.ajax()
the above callbacks work as success
error
and complete
respectively
Hope this helps