473,386 Members | 1,758 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,386 software developers and data experts.

Ajax multiple response from php file

vivekgs2007
Hi to all,
I am new to Ajax..I used a ajax in my application in that...OnSelect the name and date the ajax function goes to the php query file.
It performs the operation of sql and returns the row details in a ajaxDispaly variable...
My question is to display the row details separately in different text boxes....
My ajax code is
Expand|Select|Wrap|Line Numbers
  1.     function ajaxFunction()
  2.     { 
  3.  
  4.         var student_id=document.frmMedicaldetail.student_id.value;
  5.         var grade=document.frmMedicaldetail.grade.value;
  6.         var ajaxRequest; // The variable that makes Ajax possible!
  7.         try
  8.         {
  9.             ajaxRequest = new XMLHttpRequest();
  10.         } 
  11.         catch (e)
  12.         {
  13.             try{
  14.             ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  15.             } 
  16.             catch (e) 
  17.             {
  18.                 try{
  19.                 ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  20.             }
  21.             catch (e)
  22.             {
  23.                 alert("Your browser broke!");
  24.                 return false;
  25.             }
  26.             }
  27.         }
  28.  
  29.             ajaxRequest.onreadystatechange = function()
  30.             {
  31.                 if(ajaxRequest.readyState == 4)
  32.                 {
  33.  
  34.                     var ajaxDisplay = ajaxRequest.responseText;
  35.                     var edit_sick = ajaxDisplay;
  36.  
  37.                     //document.frmMedicaldetail.edit_age.value = edit_sick;
  38.                     alert(ajaxDisplay);
  39.                 }
  40.             }
  41.  
  42.             var edit_date =  document.getElementById('edit_date').value;
  43.  
  44.             if(grade!="" && student_id!="" && edit_date!="")
  45.             {  
  46.                 var queryString = "?grade=" + grade + "&student_id=" + student_id + "&edit_date=" + edit_date;
  47.                 ajaxRequest.open("POST","sick_ajax.php"+queryString,true);
  48.                 ajaxRequest.send(null);
  49.             }        
  50.  
  51.  
  52.     }      
  53.  
  54.  
  55. </SCRIPT>
  56.  
and my php code is
Expand|Select|Wrap|Line Numbers
  1.     $edit_date=$edit_date;
  2.     $grade=$grade;
  3.     $student_id=$student_id;
  4.     $abr=mysql_query("select * from doc_detail where course_id='$grade' and d_date='$edit_date' and stud_id='$student_id' group by stud_id");
  5.     $abr_row=mysql_fetch_array($abr);
  6.     $edit_id = $abr_row['id'];
  7.     $edit_age = $abr_row['age'];
  8.     $edit_sex = $abr_row['sex'];
  9.     $edit_adm_type = $abr_row['adm_type'];
  10.     $edit_acc_year = $abr_row['acc_year'];
  11.     $edit_complaints = $abr_row['complaints'];
  12.     $edit_treatment = $abr_row['treatment'];
  13.     $edit_remarks = $abr_row['remarks'];
  14.     $edit_time = $abr_row['time'];
  15.     echo $edit_age;
  16.     echo $edit_sex;
  17.  
Please any tell me the result..i am very nearer to death line...
Jun 2 '10 #1
2 5140
You can do something like this. In php page,
Expand|Select|Wrap|Line Numbers
  1.  echo $edit_age .'#'. $edit_sex;
Then in the ajax response,

Expand|Select|Wrap|Line Numbers
  1. var ajaxDisplay = ajaxRequest.responseText;
  2. var res=ajaxDisplay.split("#");
  3. document.frmMedicaldetail.edit_age.value = res[0];
  4. document.frmMedicaldetail.edit_sex.value = res[1];
  5.  
Jun 3 '10 #2
@paulrajj
Thank you very much i got it
Jun 17 '10 #3

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

Similar topics

3
by: Keith | last post by:
I am writing a web service that sends work to a system that gets it's work via XML files. This system looks for files in a particular directory, processes the file, then leaves a response file in...
2
by: Robert | last post by:
I am attempting to run setup on a v7.2 EE CD using a response file as input. This should result in my existing server configuration being replicated on a new server. My problem is that I have 18...
3
by: Analyst | last post by:
Is it possible to install DB2 CAE v5.2 using a response file ? From one of IBMs tech article, I found that the IBM DB2 Universal DB can be installed using a response file. My objective it to...
0
by: Guest | last post by:
Hi! Could anyone help me with my problem? I have a VC++.Net project. Project specific defines and includepaths are saved in an external file (response file) as compileroptions. I use the file...
2
by: Alexander Zauzolkov | last post by:
Hi! I have a VC++.Net project. Project specific defines and include paths are saved in an external file (response file). I use the file during compilation giving it by means of the @ compiler...
0
by: amitp | last post by:
Can anyone help me out in this? I want to append multiple RTF file into one RTF file. I tried using 'streamwriter', the resulting file size becomes big and when i open it, it is the original i.e the...
1
by: trpost | last post by:
How can I accomplish the following using AJAX / PHP: I have a form with a text field and a search button next to the text field. When I type something in the text field and hit the search button...
1
by: goelamit1982 | last post by:
How to Read multiple text file using XML and store into the database
3
by: Scav | last post by:
Helpful folks, We have recently migrated from V7 to V8 of UDB on Windows 2003. We are now in the process of setting up a rollout deployment to upgrade all of our user clent PC's from the V7...
2
by: ganeshmn25 | last post by:
Hi Folks, I have installed DB2 ESE 8.2 in my local system and created a response file called PROD_ESE , Now i need to install the response file in another system so that i can have...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.