Skip to content

Instantly share code, notes, and snippets.

@aurorapar
Created November 14, 2016 22:15
Show Gist options
  • Save aurorapar/437fe51aa228ee438660026caa227e83 to your computer and use it in GitHub Desktop.
Save aurorapar/437fe51aa228ee438660026caa227e83 to your computer and use it in GitHub Desktop.
var url = "http://localhost/lab8/php/driver.php";
window.onload = init;
function init()
{
$("#submitselect").click(submitQuery);
}
function submitQuery(event)
{
var country = $('#countryselect').val();
var city = $('#cityselect').val();
var population = $('#popselect').val();
$.ajax({
type: "POST",
url: url,
data: "country="+country+"&city="+city+"&population="+population,
success: function(response)
{
alert(response);
}
});
}
<?phpin
echo $_POST['country'];
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>World Data</title>
<link href="styles/styles.css" media="all" rel="Stylesheet" type="text/css" />
<script src="js/driver.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<?php include('php/driver.php');?>
</head>
<body>
<header>
</header>
<h1>Make a selection</h1>
<form id="formselect">
Country: <input id="countryselect" type="text" name="country" placeholder="United States">
<br><br>
City: <input id="cityselect" type="text" name="city" placeholder="Chicago">
<br><br>
Population: <input id="popselect" type="text" name="population" placeholder="1000000">
<br>
<p>
<input id="submitselect" type="submit">
</form>
<div id="result"></div>
<footer>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment