473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Sending Specific PHP Array Value with Ajax

1
I have a method to send PHP array values via Ajax to another PHP file that processes my request, however I cannot get it to work here.

I know this is normally a basic and very general error, but I cannot figure out how I am getting it.

I am trying to program a specific event calendar, the issue is on one of the events. I am trying to allow users to rate other users that went to the event.

The below code lists the users, and attempts to send a variable via Ajax to another page that processes the SQL.


CODE
---------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. $result2 = mysql_query("SELECT gp_event_user FROM gp_event_users WHERE gp_event_id='" . $ev_id . "'");
  2.  
  3. while($participant_row = mysql_fetch_array($result2))
  4. {
  5.  
  6. echo "
  7.  
  8. <div class='pingit'>
  9.  
  10. <div id='navvcontainer'>
  11. <ul id='navvlist'>
  12. <form><input type='hidden' id='eventnumber' value=" . $ev_id . " disabled='disabled' />
  13. </form>
  14. <li><img src='http://localhost/comm/img/up2.gif' class='pointer' onmousedown='ajaxPingUp(" . $participant_row['gp_event_user'] . ")' border='0' /></li>
  15. <li><a class='middle' href='#'>";
  16. echo $participant_row['gp_event_user'];
  17. echo "<font color='#FF5F11'>[24]</font></a></li>
  18. <li><a class='out' href='#'><img src='http://localhost/comm/img/down2.gif' border='0' /></a></li>
  19.  
  20. </ul>
  21. </div>
  22.  
  23. </div>
  24. ";
  25.  
---------------------------------------------------------------------

So basically this code lists the users, and if you click on a user it processes the Ajax function "ajaxPingUp" and sends the specific user you click on. When I click on a user I get:

Error: "the name of the user written here" undefined.

I don't recall every using the user as a variable, it's not even close to the code I'm writing.

Below is the Ajax page that is supposed to send the specific user that is supposed to get the vote.

CODE
---------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. function ajaxPingUp(gp_event_user){
  2. var ajaxRequest; // The variable that makes Ajax possible!
  3.  
  4. try{
  5. // Opera 8.0+, Firefox, Safari
  6. ajaxRequest = new XMLHttpRequest();
  7. } catch (e){
  8. // Internet Explorer Browsers
  9. try{
  10. ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  11. } catch (e) {
  12. try{
  13. ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  14. } catch (e){
  15. // Something went wrong
  16. alert("Your browser broke!");
  17. return false;
  18. }
  19. }
  20. }
  21.  
  22. // Create a function that will receive data sent from the server
  23. ajaxRequest.onreadystatechange = function(){
  24. if(ajaxRequest.readyState == 4){
  25. var ajaxDisplay = document.getElementById("ajaxDiv");
  26. ajaxDisplay.innerHTML = ajaxRequest.responseText;
  27. }
  28. }
  29.  
  30. var useraccount = document.getElementById("useraccount").value;
  31.  
  32. var ev_id = document.getElementById("eventnumber").value;
  33.  
  34. ajaxRequest.open("GET", "ajaxPingUp.php?gp_event_user=" + gp_event_user + "&eventID=" + ev_id + "&useraccount=" + useraccount + "&ms=" + new Date().getTime(), true);
  35. ajaxRequest.send(null);
  36.  
  37. }
---------------------------------------------------------------------

On the ajaxPingUp.php page I just want to be able to use " $_GET['gp_event_user']".

If you notice some quarky code, it's because I've been beating my head against the keyboard trying to figure this out. I've got everything to work expect this part. I've even used this Ajax method before to send specific Array values. Any help would be greatly, greatly appreciated. Thanks,
Sep 26 '07 #1
1 2001
dmjpro
2,476 2GB
Look !
You can't send an array like this.
Have a look at my logic, as i can't write PHP code I'm a J2EE man.

Get the array element each and append the string then on your server side simply substring it :-)

Got my point !

Kind regards,
Dmjpro.
Sep 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Geoff Cox | last post by:
Hello, I have been able to create a slider using Javascript code from the web but would like to send the slider values which are saved in an array to myself using email and the CGI/form...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
2
by: dtra | last post by:
hi all i've got this application where a user selects tabs on the page, which then loads a different section onto another section of the page we currently have it working using ajax, but we...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
1
by: empiresolutions | last post by:
im using the script.aculo.us drag n drop script. i am having an issue getting a checkbox to POST its value if checked, once the row the checkbox is in is moved. I believe that once i change the...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
0
by: Charles Crawford | last post by:
Hi, This apparently is a common problem and I've yet to read a solution that actually works for my specific situation. I have a Zebra RW220 printer that I connect to via Bluetooth connection...
8
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
2
by: Mike | last post by:
Hello, I am trying to pass a js array ,Round1, to a form and send it. I can get it to work with serialized values but I want to send the data as an array. The arrays are filled with data. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.