Reputation: 520
I'm developing an application using jQuery Mobile, Phonegap.
The function below I get data from remote server as JSON
function requestFunc() {
var el, li, i;
$.ajax({
type: 'GET',
url: "http://mobil.myservice.org/getpanodata.php",
data: 'page=2',
dataType: 'jsonp',
success: function(json_results) {
//something listing etc...
}
});
}
The function works. But i want to config page parameter dynamically. So i tried to change this code as
function requestFunc() {
var el, li, i;
$.ajax({
type: 'GET',
url: "http://mobil.myservice.org/getpanodata.php",
data: 'page=' + paramPage,
//the changes
dataType: 'jsonp',
success: function(json_results) {
//something listing etc...
}
});
}
but this time function is not working. How can I configure page GET string dynamically.
Upvotes: 1
Views: 20986
Reputation: 12438
you could try to send the data as
function requestFunc() {
var el, li, i;
var dataObj = {page : paramPage}; /* change made here */
$.ajax({
type: 'GET',
url: "http://mobil.myservice.org/getpanodata.php",
data: dataObj, /* change made here */
//the changes
dataType: 'jsonp',
success: function(json_results) {
//something listing etc...
}
});
}
The JQuery ajax() page gives a good example for the same here
Upvotes: 2