kamal213 Posted February 20, 2015 Share Posted February 20, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/ Share on other sites More sharing options...
kamal213 Posted February 20, 2015 Author Share Posted February 20, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506238 Share on other sites More sharing options...
kamal213 Posted February 20, 2015 Author Share Posted February 20, 2015 Please find attached the full jquery code, please open with notepad, tried to type the code again but its been an absolute nightmare. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506239 Share on other sites More sharing options...
kamal213 Posted February 20, 2015 Author Share Posted February 20, 2015 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> Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506241 Share on other sites More sharing options...
kamal213 Posted February 20, 2015 Author Share Posted February 20, 2015 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> Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506242 Share on other sites More sharing options...
kamal213 Posted February 20, 2015 Author Share Posted February 20, 2015 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> Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506243 Share on other sites More sharing options...
CroNiX Posted February 23, 2015 Share Posted February 23, 2015 (edited) You're not actually "using" jquery there. I see nothing jquery related. You're using pure javascript. If you used jquery's ajax() method, it would work in all browsers and you'd need a lot less code. Edited February 23, 2015 by CroNiX Quote Link to comment https://forums.phpfreaks.com/topic/294743-chrome-and-firefox-compatibility-issue-for-parsing-variables/#findComment-1506548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.