我输入了我在哪里写ID并点击按钮检查我是否有这样的ID(按功能)。数据通过jquery和运行函数进入第2页进行检查,我甚至可以将其打印到屏幕上。我需要将第二页中的函数数据发送到我的主页并使用这些数据。如何在不提交的情况下从第2页发送?
我的第一页:
$(function() {
$("#checkfin").click(function() {
var fin = $("#pinofsv").val();
$.post("checkfin.php", {
ffin: fin
}, function(result) {
$('#result').append(result);
});
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<form name="formids" id="formids" action="" method="POST">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-body">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<label>Enter your ID: <span style="color:#FF0000;">*</span></label>
</div>
<div class="col-sm-4">
<div class="input-group">
<input type="text" class="form-control input-sm" name="pinofsv" id="pinofsv" required />
<div class="input-group-addon"><a href="#" onmouseover="document.getElementById('place-holder-1').src='../svphoto.jpg';" onmouseout="document.getElementById('place-holder-1').src='';"><i class="glyphicon glyphicon-info-sign blue"></i><img src="" id="place-holder-1" style="z-index: 100; position: absolute;right: 1%;" /></a></div>
</div>
</div>
<div class="col-sm-5">
<div class="col-sm-5">
<button class="btn btn-primary" name="checkfin" id="checkfin" onclick="return false">Check </button>
</div>
<div class="col-sm-7">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<div id="result"></div>
我的第2页:
if(isset($_POST["ffin"]) && $_POST["ffin"] != "")
{
$fintrue = definePINNew($fin);
if($fintrue != "")
{
//do something for example print to screen data from function
}
}
答案 0 :(得分:0)
每当您发送请求时,您都会收到回复
if(isset($_POST["ffin"]) && $_POST["ffin"] != "")
{
$fintrue = definePINNew($fin);
if($fintrue != "")
{
echo 'JUST SEND YOUR DATA IT WILL BE THERE IN JQUERY RESPONSE';
Eg: echo json_encode($fintrue['anydata']);
// it will give you $_POST data in jquery response.
// which is at your first page.
// And parse data in JSON can easily get in jquery response
}
}
$(function() {
$("#checkfin").click(function() {
var fin = $("#pinofsv").val();
$.post("checkfin.php", {
ffin: fin
}, function(result) {
console.log(result.anydata); // you will get the data from second page here.
// result.anydata you can place it anywhere.
});
});
});