Jump to content

Recommended Posts

Hello sir,

          I am working on ajax..and i m new to it....so my script is not working properly.......my ajax script is as under:

 

 

<html>

<head>

<title>Using ajax</title>

<script language="javascript" type="text/javascript">

  var request = false;

  try {

    request = new XMLHttpRequest();alert("object created");

  } catch (trymicrosoft) {

    try {

      request = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (othermicrosoft) {

      try {

        request = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (failed) {

        request = false;

      } 

    }

  }

 

  if (!request)

    alert("Error initializing XMLHttpRequest!");

 

  function process() {

    var name = document.getElementById("name").value;

var password=document.getElementById("passwd").value;

alert(name);

    var url = "process-form.php?name=" + escape(name);

  request.open("GET", url, true);

    request.onreadystatechange = updatePage;

    request.send(null);

  }

 

  function updatePage() {

   

    alert("Server is done!");

  }

</script>

</head>

<body>

<h2><p align="center">Please fill the form</p></h2>

<form align="center" method="GET">

Name: 

<input type="text" name="name" onChange="process();"/><br/>

Password:

<input type="password" name="passwd"/><br/>

 

</form>

</body>

</html>

 

and my php script is:

 

 

<html>

<head><title>form</title>

</head>

<body>

<?php

$connection=mysql_connect("localhost","root","");

if(!$connection)

{

die('unable to connect '.mysql_error());

}

echo"$name<br/>";

?>

</body>

</html>

 

 

only it is popping an alert box.....that says "object created"

 

 

then after pressing enter...it again shows the form

pls help me out here..

Link to comment
https://forums.phpfreaks.com/topic/219724-ajax-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.