I have the form that consists of input text and button. I need to get the text from the input field and pass into the php variable. I use ajax, callback function responds to me but php doesn't get the data. Here is occurring such an error - Notice: Undefined index: site_input.
<form>
<div class="input-group">
<input type="text" class="form-control" placeholder="URL" value="">
<span class="input-group-btn">
<button id="start" class="btn" type="button">Start</button>
</span>
</div>
</form>
//jQuery
$("#start").click(function(){
$(document).ready(function(){
if(status == 0) {
$("#start").css("background-color", "red");
$("#start").text("Stop");
var site = $(".form-control").val();
$.ajax({
url: "index.php",
data: {
"site_input" : site
},
type: "POST",
success: function(data) {
alert("OK");
}
});
status = 1;
}
//index.php
$a =isset($_POST['site_input'])?$_POST['site_input']:'not yet';
echo $a ;
$value = $_POST['site_input'];
echo $value;