【发布时间】:2016-02-14 05:11:04
【问题描述】:
我已经包含了我用来计算我的方程式的 php 文件。我需要能够在不重新加载页面的情况下显示答案。我是 Ajax 概念的新手,也是 JS 的新手。任何帮助将不胜感激!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ProNexis</title>
<link rel="stylesheet" href="assets/demo.css">
<link rel="stylesheet" href="assets/form-basic.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script>
</head>
<div class="main-content">
<form id="myForm" name="myForm" class="form-basic" action="equate.php" method="POST">
<div class="form-title-row">
<h1>How much can ProNexis earn for you?</h1>
</div>
<div class="form-row">
<label>
<span>Locations</span>
<input type="text" id="branches" name="branches" placeholder="#">
</label>
</div>
<div class="form-row">
<label>
<span>Close Rate</span>
<input type="text" id="closerate" name="closerate" placeholder="%">
</label>
</div>
<div class="form-row">
<label>
<span>Average ticket size</span>
<input type="text" id="ticketsize" name="ticketsize" placeholder="$">
</label>
</div>
<div class="form-row">
<button name="calculate" class="btn btn-primary">Calculate!</button>
</div>
</form>
</div>
</body>
</html>
<?php
$branches = $_POST['branches'];
$closerate = $_POST['closerate'];
$ticketsize = $_POST['ticketsize'];
$leadsperhour = 8;
$revenue = ($branches * $leadsperhour) * $closerate * $ticketsize;
$leadsmissed = $branches * $leadsperhour;
$panswerrate = .92 * $leadsmissed;
$pcloserate = $closerate * $leadsmissed;
$prevenue = $pcloserate * $ticketsize;
echo "Your company, on average, missed " . $leadsmissed . " leads in the past hour. ";
echo "With Pronexis, you would have talked to " . $panswerrate . " of those leads, closed " . $pcloserate . " of them, and received $" . $prevenue . " more revenue!";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ProNexis</title>
<link rel="stylesheet" href="assets/demo.css">
<link rel="stylesheet" href="assets/form-basic.css">
</head>
<body>
</body>
</html>
【问题讨论】:
-
学习和使用AJAX
-
试试我的答案
-
谢谢大家的回答。效果很好!