how to load o/p of php in current page using js?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SandeepThakurala
    New Member
    • Feb 2010
    • 1

    #1

    how to load o/p of php in current page using js?

    hi i am new to web development and i am using js/ajax code to load o/p of php file in <div> tag. Now i am using a login.php file and i want that if login credentials are correct then further page should be open in current window else login fail message should be displayed below the username and password text box. following is the code i am using -
    Code:
    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 = "updateLinks.php";
        url = url+"?id="+id;
        url = url+"&pass="+pwd
        oRequest.open("GET",url,true);
        oRequest.send(null);
    }
    how can i modify the above code to do above written task?
    Last edited by gits; Feb 24 '10, 07:54 AM. Reason: added code tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I would use a plain form for that and let PHP decide what page to load. works even with JavaScript disabled.

    Comment

    Working...