Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
to pass the result of getDataIDs to a script
23/03/2010
18:24
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

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']

25/03/2010
09:52
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

25/03/2010
11:42
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

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

 
       

31/03/2010
17:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information