form POST values using ajax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    form POST values using ajax

    I am trying to get values posted by a form using ajax but i dont know how to get them. im opening a form which is also based on the ajax. here is the code.
    Code:
    function showPage(page)
    {
    var url=page;
    //url=url+"?q="+page;
    //url=url+"&sid="+Math.random();
    
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("container").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
    }
    the above code is just taking a url and displaying it into div. when im displaying a form using showPage('form. php'), the form is displayed correctly. im using the same function on the form action='showPag e('submit.php') and method='post' but this is not posting any data. please tell me wat im doing wrong and how i can get the posted data without defining any variables in the javascript. thanx

    the form code is as follows:

    Code:
    <div id="admForm">
    <form name="form1"  action="javascript:showPage('admission-form.php')" method="post">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <input type="submit" name="submit" value="Submit" />
    </form>
    </div>
  • jords
    New Member
    • Apr 2010
    • 1

    #2
    how to post sumthing that the user enter in a form

    help me pls, how to post the inputs of the user from the forms to the popup window of java pls help

    Comment

    Working...