Question

I posting my value through ajax and using the response the details will be displayed.I am getting the problem while retreiving the data.But i dono where i have mistaked,then this is the error getiing displayed frequently "There was a problem while using XMLHTTP:\n";

   in all browsers mainly in the chrome,could any one help me...

this is my code,

var xmlHttp;

try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
} catch (e) {
    // Internet Explorer 6+
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        // Internet Eplorer 5
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            alert("Your browser does not support AJAX. Download a newer browser to view this page.");
            return false;
        }
    }
}

// insert server response into HTML element
xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            MM_check_session(xmlHttp.responseText);
            var b_gc = document.getElementById(insert).value;
            document.getElementById(insert).value = xmlHttp.responseText;
            var shippingid = getCheckedValue('checkout_form', 'shippingid');
            closeMessage();
            MM_calc_shipping(shippingid);
            if (b_gc == xmlHttp.responseText) {
                MM_register();
            } else {
                error = 1;
                document.getElementById('payment_error').innerHTML = xmlHttp.responseText;
                document.getElementById(insert).value = '';
            }
        } else {
            closeMessage();
            alert("We can't process your request.Please refresh(reload) the page to proceed further:\n"
                    + xmlHttp.statusText);
        }

    }
}
displayStaticMessage(
        '<img src=' + config_MM_loader_image_path + ' alt=\'loading...Please wait\'>',
        false);

xmlHttp.open("POST", serverScript, true);
xmlHttp.setRequestHeader('Content-type',
'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader('Content-length', parameters.length);
xmlHttp.setRequestHeader('Connection', 'close');
xmlHttp.send(parameters);

any help

Was it helpful?

Solution

You seem to be incorrectly tagged as php. Also have you considered jQuery for the ease of ajax whilst using it.

as for your question could you post the code on the page where the ajax request is going to as the code here looks fine..

Edit: Where is serverScript set? change serverScript for the ajax page you are calling? http://msdn.microsoft.com/en-us/library/windows/desktop/ms757849%28v=vs.85%29.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top