POST two or more variables using AJAX
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: POST two or more variables using AJAX

  1. #1
    Join Date
    Dec 2004
    Location
    Pakistan(Skardu)
    Posts
    64

    Arrow POST two or more variables using AJAX

    hi gurus.
    how can we send two or more values of variables using AJAX to PHP script
    my code is:-
    <script type="text/javascript">
    function ajaxFunction()
    { var xmlHttp;
    try
    { // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    { // Internet Explorer
    try
    { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e)
    { try
    { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch (e)
    { alert("Your browser does not support AJAX!"); return false; } } }
    xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
    {
    document.myForm.mess.value=xmlHttp.responseText;
    }
    }
    var url="varify.php";
    // var params = document.myForm.
    var nam = document.getElementById('name').value;
    var pas = document.getElementById('pass').value;
    // alert(pass.value);
    // alert(name.value);
    params="name="+nam+"pass="+pas;//cancatenation


    // var pass = document.myForm.pass.value;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params); //here i wana send 2 parameters ie name and password

    }
    </script>

  2. #2
    Join Date
    Dec 2004
    Location
    Pakistan(Skardu)
    Posts
    64

    Re: POST two or more variables using AJAX

    hay gurus I got solution code is given below ie



    params="name="+nam+"&pas="+pas;//cancatenation
    this action ca help us to post
    Last edited by kku; April 25th, 2007 at 11:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center