AJAX xmlhttp.open sumit data using POST method

79 Views Asked by At

I am trying to send a form data using POST method and xmlhttp.open
Please help find the error in my code

function submitChat() {
    if (form1.msg.value == '' ) {
        alert ('ALL FIELDS ARE MANDATORY');
        return;
    }

    var xmlhttp = new XMLHttpRequest();
    var msg = form1.msg.value;
    var params = 'msg=helloooooooo';

    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open('POST', 'rtest.php?rid=14', true);
    xmlhttp.send(params);
}

Everything is fine and it is working with GET method. but POST method is not working. Please help.

0

There are 0 best solutions below