我有一个页面,我想在它打开时发布一些数据
$(document).ready(function() {
$.post( "suggestions.php", { 'textbox': 'Yes'} );
显然,"是"只是我测试的一个占位符,只是为了看看它是否发布了什么。奇怪的是,当我发布到一个不同的php页面时,它是有效的,当我从一个普通的非AJAX表单发布到"建议.php"时
<?php
session_start();
include_once("php/connect.php");
?>
<!doctype html>
<html>
<head>
<title>Try that</title>
</head>
<body>
<form action='suggestions.php' method='post'>
<input type='text' name='textbox' value='Yes' />
<button type='submit'>go!</button>
</form>
</body>
</html>
它是有效的,但结合起来就不行了。
好吧,我最终切换到了GET方法。原始页面只是将"文本框"信息发送给一个函数,该函数每隔一段时间加载suggestions.php?textbox= + e
。