By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

Results missing in Firefox, viewable in IE

100+
P: 219
I'm having a little trouble with my ajax. I can see my results in IE, but not firefox. I'm assuming I'm missing some syntax somewhere.

alert("Test " + results[1] + testing); returns the values in IE, but in Firefox it says undefined

Any ideas why this can happen?

Expand|Select|Wrap|Line Numbers
  1.     <cfform action="" enablecab="Yes" onSubmit="formSubmission();">
  2.     <table align="center">
  3.         <tr><td>ICU Capacity:</td><td><cfoutput query="GetConstants"><input type="Text" name="ICUCapSub" size="3" value="#ICUCap#" style="text-align: center;"> </td></tr>
  4.     <tr><td colspan="2" align="center"><input type="Submit" value="Submit">  </td></tr>
  5.     </table>
  6.     </cfform>
  7.  
Expand|Select|Wrap|Line Numbers
  1. //Retrieve XMLHttpRequest object to use for AJAX Development
  2. var xmlHttp;
  3. try{
  4. // Firefox, Opera 8.0+, Safari
  5.     xmlHttp=new XMLHttpRequest();
  6. }
  7. catch (e){
  8. // Internet Explorer
  9.   try
  10.   {
  11.   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  12.   }
  13. catch (e){
  14.   try{
  15.     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  16.     }
  17.   catch (e){
  18.     alert("Your browser does not support AJAX!");
  19.     //return false;
  20.     }
  21.   }
  22. }
  23.  
  24. function formSubmission(){
  25.     xmlHttp.open('GET', 'ConstantsSubmit_v2.cfm', true);
  26.     xmlHttp.onreadystatechange = handleHttpResponse;
  27.     xmlHttp.send(null);
  28. }
  29. function handleHttpResponse() {
  30.     alert(xmlHttp.readyState);
  31.     if (xmlHttp.readyState == 4) {
  32.         var results = xmlHttp.responseText.split(',');
  33.         var testing = xmlHttp.responseText;
  34.         alert("Test " + results[1] + testing);
  35.     }
  36. }
  37.  
  38.  
Oct 29 '07 #1
Share this Question
Share on Google+
6 Replies


100+
P: 228
jx2
what r you trying to send?(not everything can be display in alert() )
did you tried
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("myID").innerHTML=myData;
  2.  
regards
jx2
Oct 29 '07 #2

100+
P: 219
I'm sorry, I didn't post enough of the code I think.

The problem I'm having is that I don't have access to the form fields on the page I'm calling with the ajax.

Expand|Select|Wrap|Line Numbers
  1. <cfform action="javascript:formSubmission();" enablecab="Yes">
  2.     <table align="center">
  3.         <tr><td>ICU Capacity:</td><td><cfoutput query="GetConstants"><input type="Text" name="ICUCapSub" size="3" value="#ICUCap#" style="text-align: center;"> </td></tr>
  4.     <tr><td>Triaged And Waiting Capacity:</td><td><input type="Text" name="TAWCapSub" size="3" value="#TAWCap#" style="text-align: center;"></td></tr>
  5.     <tr><td>ED Side A Capacity:</td><td><input type="Text" name="EDASideCapSub" size="3" value="#EDASideCap#" style="text-align: center;"></td></tr>
  6. </table>
  7. </cfform>
  8.  
Expand|Select|Wrap|Line Numbers
  1. /***** AJAX Functions *****/
  2. function formSubmission(which,action,subPage,arg1,arg2){
  3.     //n = which.value;
  4.     //var q = 'query.cfm?accessID=';
  5.     //pageURL = subPage + arg1 + arg2 + n;
  6.     //alert(subPage);
  7.     //alert(action);
  8.     xmlHttp.open('POST', 'ConstantsSubmit_v2.cfm', true);
  9.     xmlHttp.onreadystatechange = handleHttpResponse;
  10.     xmlHttp.send(null);
  11. }
  12. function handleHttpResponse() {
  13.     alert(xmlHttp.readyState);
  14.     if (xmlHttp.readyState == 4) {
  15.         var results = xmlHttp.responseText.split(',');
  16.         var testing = xmlHttp.responseText;
  17.         alert("Test " + results[1] + results[2] + results[3] + testing);
  18.         var str = results[1];
  19.         updatepage('constants',str);
  20.     }
  21. }
  22.  
  23. //This function will update an id on a page and insert the value into it.
  24. function updatepage(pageID,str) {
  25.     document.getElementById(pageID).innerHTML = str;
  26. }
  27.  
Here I try to access the URL.ICUCapSub variable, but it's not there.

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="UpdateConstants" datasource="CodeGreyDW" dbtype="ODBC">
  2. update tblConstants 
  3. set ICUCap = '#ICUCapSub#',
  4. TAWCap = '#TAWCapSub#',
  5. EDASideCap = '#EDASideCapSub#',
  6. EDBSideCap = '#EDBSideCapSub#',
  7. EDDefAdmitsCap = '#EDDefAdmitsCapSub#',
  8. EDPotAdmitsCap = '#EDPotAdmitsCapSub#',
  9. AmbHourCap = '#AmbHourCapSub#',
  10. AMHealthCap = '#AMHealthCapSub#',
  11. ACounselCap = '#ACounselCapSub#',
  12. AcuityCap = '#AcuityCapSub#',
  13. TransferCap = '#TransferCapSub#',
  14. FWCap = '#FWCapSub#',
  15. FWTeleCap = '#FWTeleCapSub#',
  16. MSUCap = '#MSUCapSub#',
  17. ThreeCCap = '#ThreeCCapSub#',
  18. FourCap = '#FourCapSub#',
  19. PediCap = '#PediCapSub#',
  20. AdmAcuityDiv = '#AdmAcuityDiv#',
  21. TotSumDiv = '#TotSumDiv#',
  22. ResourceSumDiv = '#ResourceSumDiv#'
  23. </cfquery>
  24.  
  25. <cfoutput>112,232,#ICUCapSub#,#URL.ICUCapSub#,
  26. #Form.ICUCapSub#</cfoutput>
  27.  
Oct 30 '07 #3

100+
P: 219
I've looked all around and have found a few tutorials on forms and ajax, but none that seem to be answering my question.

I have a form that has about 10 fields on it. I want to have the form submit without having to load a new page. That's where I want ajax to come in.

Here's my javascript:

Expand|Select|Wrap|Line Numbers
  1. //Retrieve XMLHttpRequest object to use for AJAX Development
  2. var xmlHttp;
  3. try{
  4. // Firefox, Opera 8.0+, Safari
  5.     xmlHttp=new XMLHttpRequest();
  6. }
  7. catch (e){
  8. // Internet Explorer
  9.   try
  10.   {
  11.   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  12.   }
  13. catch (e){
  14.   try{
  15.     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  16.     }
  17.   catch (e){
  18.     alert("Your browser does not support AJAX!");
  19.     //return false;
  20.     }
  21.   }
  22. }
  23.  
  24. function formSubmission(){
  25.     xmlHttp.open('POST', 'ConstantsSubmit_v2.cfm', true);
  26.     xmlHttp.onreadystatechange = handleHttpResponse;
  27.     xmlHttp.send(null);
  28. }
  29.  
When the open function is called, shouldn't the page I'm calling (ConstantsSubmit_v2.cfm) have access to the form variables from the page?
Oct 30 '07 #4

acoder
Expert Mod 15k+
P: 16,027
Merged the threads because they are dealing with the same problem.
Oct 30 '07 #5

acoder
Expert Mod 15k+
P: 16,027
When the open function is called, shouldn't the page I'm calling (ConstantsSubmit_v2.cfm) have access to the form variables from the page?
When using POST, you have to send the form variables using the send() method.
Oct 30 '07 #6

100+
P: 219
When using POST, you have to send the form variables using the send() method.
Ok, so I need to loop through and retrieve all the input fields on the form before I send them. Thanks!!
Oct 30 '07 #7

Post your reply

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