baiju Posted October 3, 2006 Share Posted October 3, 2006 my prob is ajax not working in morzilla firefox..but this same code having no prob with internet explorer..here is my javascript codefunction createRequestObject(){ if (window.XMLHttpRequest) { // Mozilla, Safari, Opera... var xmlhttp = new XMLHttpRequest(); if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml'); } else if (window.ActiveXObject) { // IE try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!xmlhttp) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; }return xmlhttp;}var http = createRequestObject();function sendRequest() {var name = document.getElementById('name').value;var email = document.getElementById('email').value;var ph = document.getElementById('ph').value;var addr = document.getElementById('addr').value;var descr = document.getElementById('descr').value;http.open('post', 'mail.php');http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//alert('field='+field+'&field1'=field1);http.send('name='+name+'&email='+email+'&ph='+ph+'&addr='+addr+'&descr='+descr);//http.send('field1='+field1);http.onreadystatechange = handleDetails;}function handleDetails() { if (http.readyState == 4) { var response = http.responseText;document.getElementById('test').innerHTML = response;}} Quote Link to comment Share on other sites More sharing options...
tomfmason Posted October 3, 2006 Share Posted October 3, 2006 FF is realy picky..lol. I have had many problems with it.. Well not so much with Fire Fox but my messy code.I see that you have placed some alerts throughout the script. That is the best way that I know of to debug. Have you looked at the javascript console? Is it displaying any errors? Are you sure that you are calling the sendRequest function correctly..?If you post a link I will take a look at it with FF and Opera to see if I can find any errors. Good Luck,Tom Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted October 3, 2006 Share Posted October 3, 2006 this is my ajax obj creation function... I have no probs with it so far - works in IE FF Opera - not tested safari yet!function GetXmlHttpObject(handler){ var objXmlHttp=null; if (window.ActiveXObject) // ActiveX version { try { objXmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); objXmlHttp.onreadystatechange=handler; return objXmlHttp; } catch(e) { alert("Error. Scripting for ActiveX might be disabled"); return; } } else if (window.XMLHttpRequest) // Object of the current windows { objXmlHttp=new XMLHttpRequest(); objXmlHttp.onload=handler; objXmlHttp.onerror=handler; return objXmlHttp; }} Quote Link to comment 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.