views:

8

answers:

0

hi i am using js/ajax code to print the o/p of php file in tag, now i want to check the o/p of php file in js. Actually i have login.php page which check login credentials in db and if credentials are correct then it will return true else it will return false, then js will check returned o/p and if o/p is true then login success message will be printed else login fail will be printed. Following is the code i am using to call php from js :--

function updateLink(id,pwd){
    var oRequest;
    try {
        oRequest=new XMLHttpRequest();
    } catch (e)   {
        try {
            oRequest=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                oRequest=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    oRequest.onreadystatechange=function() {
        if(oRequest.readyState==4)
        {
            var div = window.parent.document.getElementById('result');
            div.innerHTML = oRequest.responseText;
        }
    }
    var url = "login.php";
    url = url+"?id="+id;
    url = url+"&pass="+pwd;
    oRequest.open("GET",url,true);
    oRequest.send(null);
}