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.
[code]<?php
if(isset($_POST[’email’])){
echo ‘the email is’. $_POST[’email’];
}; ?>[/code]
A1WEBSITEPRO Social Media Pages
Here are my social media pages, lets hook up!