Forum


18:24

09/11/2009

Crazy question ... for the specialists.
How to pass the content of the result of the following instruction
var m = jQuery("#list3").getDataIDs(); // ["10","21","78", .......]
to a php script ?
var getVars = "r=" + m;
$.ajax(
{
type: "GET",
url:'myscript.php',
dataType: 'script',
data: getVars,
success: function(result) {},
error: function(requete,iderror) {}
})
myscript see a string but not an array with the instruction $_GET['r']
09:52

Moderators
30/10/2007

Hello,
one possible solution is to use join to join the values and then server side to use some other function to explode the values at server - in php this is the function explode
var m = jQuery("#list3″).getDataIDs();
var mydata = m.join(",");
$.ajax(
{
type: "GET",
url:'myscript.php',
dataType: 'script',
data: {myVars: mydata},
success: function(result) {},
error: function(requete,iderror) {}
})
then use explode on myVars - i.e
myarray = explode(",",$_GET['myVars']);
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
11:42

09/11/2009

Hello Tony and thank you,
By waiting for one solution, I found this:
var z = new Array();
var m = jQuery("#list3").getDataIDs();
for (var i=0; i < m.length; i++)
{
z.push(m[i]);
};
mydata = JSON.stringify(z);
But I am obliged to add json2.js and to create an array !
Your solution seems light, mine seems strong
17:46

Moderators
30/10/2007

Hello,
If you have included the xmlJsonClass when you download the grid you can use i
xmlJsonClass.toJson function
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
39 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66