Jump to content

ajax not workng in morzilla firefox


baiju

Recommended Posts


my prob is ajax not working in morzilla firefox..
but this same code having no prob with internet explorer..

here is my javascript code


function 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;
}
}
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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;
}
}
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.