Results missing in Firefox, viewable in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmorand
    New Member
    • Sep 2007
    • 219

    Results missing in Firefox, viewable in IE

    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?

    [code=html]
    <cfform action="" enablecab="Yes" onSubmit="formS ubmission();">
    <table align="center">
    <tr><td>ICU Capacity:</td><td><cfoutpu t query="GetConst ants"><input type="Text" name="ICUCapSub " size="3" value="#ICUCap# " style="text-align: center;"> </td></tr>
    <tr><td colspan="2" align="center"> <input type="Submit" value="Submit"> </td></tr>
    </table>
    </cfform>
    [/code]

    [code=javascript]
    //Retrieve XMLHttpRequest object to use for AJAX Development
    var xmlHttp;
    try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest( );
    }
    catch (e){
    // Internet Explorer
    try
    {
    xmlHttp=new ActiveXObject(" Msxml2.XMLHTTP" );
    }
    catch (e){
    try{
    xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
    }
    catch (e){
    alert("Your browser does not support AJAX!");
    //return false;
    }
    }
    }

    function formSubmission( ){
    xmlHttp.open('G ET', 'ConstantsSubmi t_v2.cfm', true);
    xmlHttp.onready statechange = handleHttpRespo nse;
    xmlHttp.send(nu ll);
    }
    function handleHttpRespo nse() {
    alert(xmlHttp.r eadyState);
    if (xmlHttp.readyS tate == 4) {
    var results = xmlHttp.respons eText.split(',' );
    var testing = xmlHttp.respons eText;
    alert("Test " + results[1] + testing);
    }
    }

    [/code]
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    what r you trying to send?(not everything can be display in alert() )
    did you tried
    Code:
    document.getElementById("myID").innerHTML=myData;
    regards
    jx2

    Comment

    • dmorand
      New Member
      • Sep 2007
      • 219

      #3
      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.

      [code=html]
      <cfform action="javascr ipt:formSubmiss ion();" enablecab="Yes" >
      <table align="center">
      <tr><td>ICU Capacity:</td><td><cfoutpu t query="GetConst ants"><input type="Text" name="ICUCapSub " size="3" value="#ICUCap# " style="text-align: center;"> </td></tr>
      <tr><td>Triag ed And Waiting Capacity:</td><td><input type="Text" name="TAWCapSub " size="3" value="#TAWCap# " style="text-align: center;"></td></tr>
      <tr><td>ED Side A Capacity:</td><td><input type="Text" name="EDASideCa pSub" size="3" value="#EDASide Cap#" style="text-align: center;"></td></tr>
      </table>
      </cfform>
      [/code]
      [code=javascript]
      /***** AJAX Functions *****/
      function formSubmission( which,action,su bPage,arg1,arg2 ){
      //n = which.value;
      //var q = 'query.cfm?acce ssID=';
      //pageURL = subPage + arg1 + arg2 + n;
      //alert(subPage);
      //alert(action);
      xmlHttp.open('P OST', 'ConstantsSubmi t_v2.cfm', true);
      xmlHttp.onready statechange = handleHttpRespo nse;
      xmlHttp.send(nu ll);
      }
      function handleHttpRespo nse() {
      alert(xmlHttp.r eadyState);
      if (xmlHttp.readyS tate == 4) {
      var results = xmlHttp.respons eText.split(',' );
      var testing = xmlHttp.respons eText;
      alert("Test " + results[1] + results[2] + results[3] + testing);
      var str = results[1];
      updatepage('con stants',str);
      }
      }

      //This function will update an id on a page and insert the value into it.
      function updatepage(page ID,str) {
      document.getEle mentById(pageID ).innerHTML = str;
      }
      [/code]
      Here I try to access the URL.ICUCapSub variable, but it's not there.

      [code=cfm]
      <cfquery name="UpdateCon stants" datasource="Cod eGreyDW" dbtype="ODBC">
      update tblConstants
      set ICUCap = '#ICUCapSub#',
      TAWCap = '#TAWCapSub#',
      EDASideCap = '#EDASideCapSub #',
      EDBSideCap = '#EDBSideCapSub #',
      EDDefAdmitsCap = '#EDDefAdmitsCa pSub#',
      EDPotAdmitsCap = '#EDPotAdmitsCa pSub#',
      AmbHourCap = '#AmbHourCapSub #',
      AMHealthCap = '#AMHealthCapSu b#',
      ACounselCap = '#ACounselCapSu b#',
      AcuityCap = '#AcuityCapSub# ',
      TransferCap = '#TransferCapSu b#',
      FWCap = '#FWCapSub#',
      FWTeleCap = '#FWTeleCapSub# ',
      MSUCap = '#MSUCapSub#',
      ThreeCCap = '#ThreeCCapSub# ',
      FourCap = '#FourCapSub#',
      PediCap = '#PediCapSub#',
      AdmAcuityDiv = '#AdmAcuityDiv# ',
      TotSumDiv = '#TotSumDiv#',
      ResourceSumDiv = '#ResourceSumDi v#'
      </cfquery>

      <cfoutput>112,2 32,#ICUCapSub#, #URL.ICUCapSub# ,
      #Form.ICUCapSub #</cfoutput>
      [/code]

      Comment

      • dmorand
        New Member
        • Sep 2007
        • 219

        #4
        Tutorial on how to submit a form using ajax?

        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:

        [code=javascript]
        //Retrieve XMLHttpRequest object to use for AJAX Development
        var xmlHttp;
        try{
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest( );
        }
        catch (e){
        // Internet Explorer
        try
        {
        xmlHttp=new ActiveXObject(" Msxml2.XMLHTTP" );
        }
        catch (e){
        try{
        xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
        }
        catch (e){
        alert("Your browser does not support AJAX!");
        //return false;
        }
        }
        }

        function formSubmission( ){
        xmlHttp.open('P OST', 'ConstantsSubmi t_v2.cfm', true);
        xmlHttp.onready statechange = handleHttpRespo nse;
        xmlHttp.send(nu ll);
        }
        [/code]

        When the open function is called, shouldn't the page I'm calling (ConstantsSubmi t_v2.cfm) have access to the form variables from the page?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Merged the threads because they are dealing with the same problem.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by dmorand
            When the open function is called, shouldn't the page I'm calling (ConstantsSubmi t_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.

            Comment

            • dmorand
              New Member
              • Sep 2007
              • 219

              #7
              Originally posted by acoder
              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!!

              Comment

              Working...