我在页面上有3个提交按钮。
$scope.rawUsers = angular.copy($scope.users);
和PHP代码:
<form class="" action="" method="POST">
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="elevator">ლფტის შეკვეთა</button>
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="eskalator">ესკალატორის შეკვეთა</button>
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="parts">ნაწილების შეკვეთა</button>
</form>
如何在不刷新页面的情况下执行此操作。请帮忙
答案 0 :(得分:0)
>> You can made two .php file (example)
1)index.php
2)postdata.php
//index.php
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('.mosh-btn').on('click',function (e) { //e.preventDefault();
var formData = $(this).val();
var formData = 'type='+formData;
alert(formData)
$.ajax({
type: 'post',
url: 'postdata.php',
data: formData,
success: function (data) {
alert(data);
}
});
return false;
});
});
</script>
<form class="" action="" method="POST">
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="elevator">ლფტის შეკვეთა</button>
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="eskalator">ესკალატორის შეკვეთა</button>
<button type="submit" name="type" class="btn mosh-btn mosh-btn-2" value="parts">ნაწილების შეკვეთა</button>
</form>
//postdata.php
<?php
if (!isset($_POST['type']))
{
echo $type = $_POST['type'];
include 'inc/liftorderform.php';
}elseif ($_POST['type'] == 'elevator')
{
echo $type = 'liftorderform.php';
//include 'inc/liftorderform.php';
}elseif ($_POST['type'] == 'eskalator')
{
echo $type = 'inc/eskalatororderform.php';
include 'inc/eskalatororderform.php';
}elseif ($_POST['type'] == 'parts')
{
echo $type = 'inc/partsorderform.php';
include 'inc/partsorderform.php';
}
?>