好,这就是我得到的,基本上是单击一个按钮并执行以下代码:
Readthis = "MonsterRequest.php?id=<?php echo $_REQUEST['id']; ?>&Mon=";
TestVar = TestVar.replace(/\s/g, "");
Readthis = Readthis + htmlencode(TestVar);
$('#CenterPiece').load(Readthis);
除了传递给Monsterequest.php以外,其他所有内容似乎都按预期工作,该帖子没有传递到其自身上,并且页面在传递给主要父对象时基本上重新加载了它的自我…(我不确定是否是,但是monsterrequest.php本身似乎可以很好地工作,但是在加载时它根本无法按预期工作,我完全感到困惑,我基本上想发布数据而不重新加载页面。
您熟悉AJAX吗?如果您已经知道,请原谅我,但是如果您不知道,请原谅我:
Ajax将数据发布到外部php文件,该文件处理接收到的数据,并发送回答案。看起来像这样:
文件1:
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#Sel').change(function() {
var opt = $(this).val();
var someelse = 'Hello';
var more_stuff = 'Goodbye';
$.ajax({
type: "POST",
url: "receiving_file.php",
data: 'selected_opt=' + opt + '&something_else=' +someelse+'&more_stuff='+more_stuff,
success:function(data){
alert('This was sent back: ' + data);
}
});
});
});
</script>
</head>
<body>
<select id = "Sel">
<option value ="Song1">default value</option>
<option value ="Song2">Break on through</option>
<option value ="Song3">Time</option>
<option value ="Song4">Money</option>
<option value="Song5">Saucerful of Secrets</option>
</select>
文件#2:receiving_file.php
<?php
$recd = $_POST['selected_opt'];
echo 'You chose: ' . $recd;