Reputation: 23
I'm trying to develop a mobile app with phonegap but I have a problem.
function onBodyLoad(){
$('#contentdining').load('http://localhost/m/contentdining.php',
{reloadPage:true});
var id = getUrlVars()["id"];
var product = serviceURL+'contentproduct.php?id='+id;
$('#contentproduct').load(product,{reloadPage:true});
});
In index.html, my problem is "can not refresh"
Upvotes: 0
Views: 3901
Reputation: 23
done...thanks for all + @jasper too..i got other solution...i m last time use refresh for get parameter in URL ( using GET ) ..but 1 day find them still can'not
for now im use other solution ( POST ) method
this my code
in php
<a href="#product?id=<?php echo $row_getd['id_product']; ?>" style="text-decoration:none;color:#333;" onclick="onBodyLoad1(<?php echo $row_getd['id_product'];?>);">
in .js
var serviceURL = "http://localhost/m/";
//var serviceURL = "http://kimpuler.com";
function onBodyLoad1(idku){
var id = getUrlVars()["id"];
var product = serviceURL+'contentproduct.php?id='+id;
$("#contentproduct").load(product,{'id':idku}, function(){
location.reload;
});
hope can help for other people when same problem like me..
thanks @jasper also..you really great person...your code give me inspiration and will use in future...
Regard jk
Upvotes: 0
Reputation: 76003
The reloadPage
option is not valid for the .load()
function, it's for the $.mobile.changePage()
function:
$.mobile.changePage('some-url.html', {
reloadPage : true
});
Documentation: http://jquerymobile.com/demos/1.1.0/docs/api/methods.html
Be aware that this only works for external pages. So if your app has all the pseudo-pages in one HTML file you can't use this feature. You can however if you just pull the pseudo-page out of the single HTML document and making one of it's own.
Otherwise you can use .load()
to reload a page but make sure that the HTML returned from the server creates a valid jQuery Mobile page structure:
<div data-role="page">
<div data-role="content">
...
</div>
</div>
Here is the documentation for .load()
: http://api.jquery.com/load/
Notice that the way you're using .load()
you are passing a data object so the URL you're loading receives a GET variable named reloadPage
set to true
. So to make your page work with .load()
, simply remove the { reloadPage : true }
.
You could be having issues with caching, in which case I recommend using $.ajax()
so you can specify to not allow cached content:
$.ajax({
url : serviceURL + 'contentproduct.php?id=' + getUrlVars()["id"],
type : 'get',
cache : false,
success : function (response) {
$('#contentproduct').html(response);
},
error : function (a, b, c) { console.log(b); }
});
Setting cache : false
places a time-stamp on the end of the AJAX request's URL so a new version is grabbed each time.
Upvotes: 1