Best Ajax Tutorial Simple and Easy to understand

Ajax  Code to Get You Started

Here are the 2 different codes that I use in the video to help you get started.

Create a file and call it index.php.

[code]<html>
<head>
<title>Ajax Example</title>
</head>
<body>
<input type="email" id="email" size="50" placeholder="Email Address">
<button type="button" id="subsub" onclick="ajax_post();">Subscribe</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 vars = "email="+emm;
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>[/code]

Create another file and call it processor.php. Here is the code for that file.

Only cool people share!

[code]<?php
if(isset($_POST[’email’])){
echo ‘the email is’. $_POST[’email’];
}; ?>[/code]

Best Ajax Tutorial Simple and Easy to understand was last modified: June 11th, 2017 by Maximus Mccullough
Summary
Best Axjax Tutorial Simple and Easy to understand
Article Name
Best Axjax Tutorial Simple and Easy to understand
Description
This is the best Ajax tutorial. Learn how to submit a form without reloading a page. Ajax can do that for you. Here is a very simple tutorial with the code that will help you get started on your way to using Ajax in your applications.
Author
Publisher
A1WEBSITEPRO LLC
Logo
best-ajax-tutorial simple and easy to understand

Pages:Previous 1 2

Leave a Reply

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