Ajax How To Process More Than One Form Item

Ajax Scripts

Make an index.php file and put the following lines of code in it.

<html>
<head>
<title>Ajax Process More than one form item.</title>
</head>
<body>
<input type="email" id="email" size="50" placeholder="Email Address">
<input type="text" id="name" size="50" placeholder="Name">
<button type="button" id="subsub" onclick="ajax_post();">GO</button><br/> <div id="status"></div>
<script>
function ajax_post(){
var hr = new XMLHttpRequest();
var url = "processor.php";
var emm = document.getElementById("email").value;
var name1 = document.getElementById("name").value;
var vars = "email="+emm+"&namee="+name1;
hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function()
{ if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText; document.getElementById("status").innerHTML = return_data;
}
}
hr.send(vars); // After Check Steps are done execute the request
document.getElementById("status").innerHTML = "processing..."; } </script>
</body>
</html>

Make a processor.php file

Now make a processor.php file and put these lines of code in it. It is important to note that you must do this on a computer or server that has a PHP processor on it.

<?php if(isset($_POST['email'])){ $email=$_POST['email']; $name=$_POST['namee']; echo 'the email is '. $email.' The name is '.$name; }; ?>

Ajax How To Process More Than One Form Item was last modified: March 15th, 2023 by Maximus Mccullough
Summary
Ajax How To Process More Than One Form Item
Article Name
Ajax How To Process More Than One Form Item
Description
In this Ajax tutorial you will learn how to process more than one form item. Ajax is very fast and can retrieve data in a split second. The key ingredient is the way you set the variables in the script.
Author
Publisher
A1WEBSITEPRO LLC
Logo
Ajax How To Process More Than One Form Item

Pages:Previous 1 2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.