468,541 Members | 1,820 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,541 developers. It's quick & easy.

passing array to php from Ajax

omerbutt
638 512MB
hi
i have an html input which is built from php and have an onclick function that calls the javascript function and sends some arrays to that function which are initialized via php and then passed to javascript function and then again submitted to a php file via an AJAX call but the problem is that when passed to the php file via AJAX it try to echo those arrays , they show me the following rather than the values
Expand|Select|Wrap|Line Numbers
  1. <pre>function Array() {
  2.     [native code]
  3. }</pre></pre>function Array() {
  4.     [native code]
  5. }<pre>function Array() {
  6.     [native code]
  7. }</pre>
  8.  

here is the js function

Expand|Select|Wrap|Line Numbers
  1. var xmlGuestInfo=null;
  2.     function getGuestInfo(mbr,id,t_days,type,t_guests,t_stays,all_dates,unique_dates,guest_beds_arranged){
  3.         var guest_name    =    document.getElementById("guest_name_"+id).value;
  4.         if(mbr=="" && guest_name==""){
  5.             displayError("Please Enter Guest Name to proceed.");
  6.             if(document.getElementById("guest_price_"+id).value!=''){
  7.                 document.getElementById("total_price").value=document.getElementById("total_price").value.substr(0,parseFloat(document.getElementById("total_price").value.length) - parseFloat(1))-parseFloat(document.getElementById("guest_price_"+id).value.substr(0,parseFloat(document.getElementById("guest_price_"+id).value.length) - parseFloat(1)))+"$";
  8.                 document.getElementById("guest_price_"+id).value='';
  9.             }
  10.         }else{
  11.             if(guest_name=="" && type=="MBR"){
  12.                 displayError("Please enter guest name before entering the MBR#");
  13.             }else if(guest_name=="" && type=="GST"){
  14.                 displayError("Please enter guest name");
  15.             }else{
  16.                 var str=encodeURI("guest_name="+guest_name+"&member_id="+mbr+"&t_days="+t_days+"&row_id="+id+"&t_guests="+t_guests+"&t_stays="+t_stays+"&all_dates="+all_dates+"&unique_dates="+unique_dates+"&guest_beds_arranged="+guest_beds_arranged);
  17.                 var url="index.php?option=com_reservations&task=checkMember&format=raw&"+str;
  18.                 xmlGuestInfo=GetXmlHttpObject();
  19.                 if(xmlGuestInfo==null){
  20.                     alert("Please upgrade your browser");
  21.                     return;
  22.                 }else{
  23.                     xmlGuestInfo.onreadystatechange=$getGuestInfo;
  24.                     xmlGuestInfo.open("GET",url,true);
  25.                     xmlGuestInfo.send(null);
  26.                 }
  27.             }
  28.         }
  29.  
  30.     }
  31. function $getGuestInfo(){
  32.         if(xmlGuestInfo.readyState==4){
  33.             if(xmlGuestInfo.status==200){
  34.                 alert(xmlGuestInfo.responseText);
  35.                 return;
  36.             }
  37.         }
  38.  
  39.     }
  40.  
Nov 1 '11 #1

✓ answered by omerbutt

that was not the problem :) , but solved anyhow
thanks
,
Omer Aslam

2 1940
johny10151981
1,059 1GB
here is an example of how to send an array of data

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     print_r($_GET);
  3. ?>
  4. <FORM action=''>
  5. <input name='pp[]'>
  6. <input name='pp[]'>
  7. <input name='pp[]'>
  8. <input type='submit'>
  9. </FORM>
  10.  
Nov 3 '11 #2
omerbutt
638 512MB
that was not the problem :) , but solved anyhow
thanks
,
Omer Aslam
Nov 10 '11 #3

Post your reply

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

Similar topics

5 posts views Thread by Raju V.K | last post: by
5 posts views Thread by Oeleboele | last post: by
6 posts views Thread by DeepaK K C | last post: by
3 posts views Thread by Albert Albani | last post: by
2 posts views Thread by Neil Munro | last post: by
3 posts views Thread by jrogers.sw | last post: by
1 post views Thread by tlinzy | last post: by
25 posts views Thread by Geoff Cox | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.