Jump to content

Chrome and Firefox compatibility issue for parsing variables


kamal213

Recommended Posts

Hi guys

 

The code below is meant to parse variables from one page/file to the next.

 

It works perfectly on all IE's but not on Firefox or Chrome for some reason.

 

Could you have a look please for the reason why it doesn't work on Firefox and Chrome and how this could be solved.

 

Thanks a lot.

 

 

<script language="JavaScript" type="text/javascript">
function ajax_post(){
  //Create XMLHttpRequest object
 
Link to comment
Share on other sites

Sorry guys please ignore the above

 

I submitted the topic half way through typing by accident. this system is has been a nightmare to use.

 

Tried to see if I could edit it but you cant copy and paste or upload so had to type the code again only to press submit and discover I cant save changes cause I don't have permission so I bit upset.

 

Will try and type this again so please bear with me

Link to comment
Share on other sites

Hi there

 

Ok tried to uploads the file but that doesn't work either so I'll start typing the code in full again.

 

Below is the full jquery script responsible for parsing variable between file. it work fine in Internet explorer but not on Chrome or firefox.

 

 

<script language = "JavaScript"  type = "text/javascript">
function ajax_post(){
            // Create our XMLHttpRequest object
            var hr = new XMLHttpRequest();
           // Create some variables needed to send to our PHP file
           var url = "orderfilefunc.php";
           var sd = document.getElementById("startdate").value;
           var ed = document.getElementById("enddate"). value;
           var ot = document.getElementById("ordertype").value;
           var vars = "startdate="+sd+"&enddate="+ed+"&ordertype="+ot;
           hr.open("POST", url, true);
          // SET content type header information for sending url encoded variables in the request
          hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
         // Access the onreadystatechange event for the XMLHttpRequest object
         hr.onreadystatechange = function() {
                          if(hr.readyState == 4 && hr.status == 200) {
                                                 //alert("form was submitted");
                                           var return_data = hr.responseText;
                                       document.getElementById("status").innerHTML = return_data;
            }
 
     }
     // Send the data to PHP now... and wait for response to update the status div
     hr.send(vars); //Actually execute the request
     document.getElementById("status").innerHTML = "processing...";
 
 
}
 
<script>
Link to comment
Share on other sites

Hi there

 

Ok tried to uploads the file but that doesn't work either so I'll start typing the code in full again.

 

Below is the full jquery script responsible for parsing variable between file. it work fine in Internet explorer but not on Chrome or firefox.

 

 

<script language = "JavaScript"  type = "text/javascript">
function ajax_post(){
            // Create our XMLHttpRequest object
            var hr = new XMLHttpRequest();
           // Create some variables needed to send to our PHP file
           var url = "orderfilefunc.php";
           var sd = document.getElementById("startdate").value;
           var ed = document.getElementById("enddate"). value;
           var ot = document.getElementById("ordertype").value;
           var vars = "startdate="+sd+"&enddate="+ed+"&ordertype="+ot;
           hr.open("POST", url, true);
          // SET content type header information for sending url encoded variables in the request
          hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
         // Access the onreadystatechange event for the XMLHttpRequest object
         hr.onreadystatechange = function() {
                          if(hr.readyState == 4 && hr.status == 200) {
                                                 //alert("form was submitted");
                                           var return_data = hr.responseText;
                                       document.getElementById("status").innerHTML = return_data;
            }
 
     }
     // Send the data to PHP now... and wait for response to update the status div
     hr.send(vars); //Actually execute the request
     document.getElementById("status").innerHTML = "processing...";
 
 
}
 
<script>
Link to comment
Share on other sites

Hi there

 

Ok tried to uploads the file but that doesn't work either so I'll start typing the code in full again.

 

Below is the full jquery script responsible for parsing variable between file. it work fine in Internet explorer but not on Chrome or firefox.

 

 

<script language = "JavaScript"  type = "text/javascript">
function ajax_post(){
            // Create our XMLHttpRequest object
            var hr = new XMLHttpRequest();
           // Create some variables needed to send to our PHP file
           var url = "orderfilefunc.php";
           var sd = document.getElementById("startdate").value;
           var ed = document.getElementById("enddate"). value;
           var ot = document.getElementById("ordertype").value;
           var vars = "startdate="+sd+"&enddate="+ed+"&ordertype="+ot;
           hr.open("POST", url, true);
          // SET content type header information for sending url encoded variables in the request
          hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
         // Access the onreadystatechange event for the XMLHttpRequest object
         hr.onreadystatechange = function() {
                          if(hr.readyState == 4 && hr.status == 200) {
                                                 //alert("form was submitted");
                                           var return_data = hr.responseText;
                                       document.getElementById("status").innerHTML = return_data;
            }
 
     }
     // Send the data to PHP now... and wait for response to update the status div
     hr.send(vars); //Actually execute the request
     document.getElementById("status").innerHTML = "processing...";
 
 
}
 
<script>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.