+ Reply to Thread
Results 1 to 2 of 2

ajax doubt

This is a discussion on ajax doubt within the Computer Science & IT Engineering forums, part of the CE : Technical Discussions category; HTML Code: <html> <body> <script type= "text/javascript" > function ajaxfunction() { var y=document.myform.na.value; var z=document.myform.time.value; var x; try { x=new ...

  1. #1
    CE - Newbie
    Join Date
    2nd October 2008
    I'm a crazy: Computer Science engineer

    Posts
    2

    Default ajax doubt

    HTML Code:
    <html>
    <body>
    <script type="text/javascript">
    function ajaxfunction()
    {
    var y=document.myform.na.value;
    var z=document.myform.time.value;
    var x;
    try
    {
    x=new XMLHttpRequest();
    }
    catch(e)
    {
    try
    {
    x=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
    try
    {
    x=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e)
    {
    alert("Your browser does not support AJAX :(");
    return false;
    }
    }
    }
    
    x.onreadystatechange=function()
    {
    if(x.readyState==4)
    {
    document.myform.time.value=x.responseText;
    }
    }
    var url="time.php";
    url=url + "?q=" + y ;
    url=url + "&sid =" + Math.random();
    x.open("GET", url , true);
    x.send(null);
    }
    </script>
    <form name="myform">
    Name: <input type="text"  name="na"/>
    Time: <input type="text" name="time"/>
    <input type="button" onclick="ajaxfunction();" name="btn">
    </form>
    </body>
    </html> 
    this is jus a prog in ajax to check if the username and password are correct???
    i jus don get the three lines below:

    var url="time.php";
    url=url + "?q=" + y ;
    url=url + "&sid =" + Math.random();

    x.open("GET", url , true);
    x.send(null);

    how is q assigned the correct value??? of y and wht ll be the variable url while sending??

    also i need to attach one more value to the url, it is z here..

    in the php code, the stmt
    $n=$_GET["q"];
    exactly retrieves the value of q and assigns it to n...

    so jus say what does that ? and = mean and how they are assigned

    thnx in advance
    Last edited by The_Big_K; 11th October 2008 at 01:40 PM.

  2. #2
    CE - Regular Member
    Join Date
    25th September 2008
    I'm a crazy: CSE engineer

    Posts
    65

    Thumbs up Re: ajax doubt

    Hi gijoe,

    This is the line which reads value of name in y
    var y=document.myform.na.value;

    When you click a submit ajaxfunction is called.

    if you write "crazyengineer" in input filed the url formed will be


    http://servername/time.php?q=crazyengineer&sid=8948923

    sid will have a random number this is just to take care that each time a new url is produced or else there may be a possibility that browser cache will give old values!

    Thanks & Regards
    Sriram

+ Reply to Thread

LinkBacks (?)

  1. 11th October 2008, 01:20 PM

Similar Threads

  1. AJAX(Asynchronous JavaScripting and XML)
    By Mahesh in forum Computer Science & IT Engineering
    Replies: 3
    Last Post: 27th December 2009, 09:55 PM
  2. Ajax Technology
    By pankaj.sharma in forum Computer Science & IT Engineering
    Replies: 1
    Last Post: 2nd November 2007, 11:44 AM
  3. Difference b/w JSF and AJAX
    By magakamal in forum Computer Science & IT Engineering
    Replies: 1
    Last Post: 27th April 2007, 01:46 PM
  4. PHP / AJAX experts, anyone?
    By The_Big_K in forum Computer Science & IT Engineering
    Replies: 17
    Last Post: 9th November 2006, 11:48 AM
  5. PHP Symfony and AJAX
    By kidakaka in forum Computer Science & IT Engineering
    Replies: 0
    Last Post: 19th October 2006, 02:37 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