我有网页A.用户点击表单提交数据,然后将他带到网页B.当他点击后退按钮时,我需要从服务器刷新网页A,而不是从缓存加载.我有这个:<meta http-equiv="expires" content="0">但似乎没有用.我也尝试在页面B上设置变量(通过php设置会话变量)然后在页面A上检查它并根据它的存在刷新(或不刷新).这种做法似乎也有效.基本代码是:页面A:
<?php
if(isset($_SESSION['reloadPage'])) {
unset($_SESSION['reloadPage']);
echo'
<script>
window.location.replace("/****/****/*****.php");
</script>
';
}
?>
Run Code Online (Sandbox Code Playgroud)
在第B页:
$_SESSION['reloadPage'] = 1;
Run Code Online (Sandbox Code Playgroud)
使用PHP解决方案,它只是不断尝试在永无止境的循环中刷新页面.我的逻辑缺少什么?这是正确的方法吗?
编辑 经过进一步调查,当您告诉浏览器不缓存页面时,这是否会强制完整的服务器端刷新?这就是我需要的.页面的完整服务器端刷新.
由于我不知道的原因,我的表单没有提交输入我的文本<textarea>.
ajax代码:
$.ajax({
type:'POST',
url:'****.php',
data:$('#blogForm').serialize(),
success: function(responseSubmit) { blah blah etc...
Run Code Online (Sandbox Code Playgroud)
输入工作正常,并正确发布到我的数据库.
表格是:
<form id="blogForm">
<input type="date" name="date" id="blogDate">
<input type="text" name="title" id="blogTitle">
<textarea name="blogContent" id="blogBody"></textarea>
<input type="submit" name="submit" id="blogSubmit">
</form>
Run Code Online (Sandbox Code Playgroud)
当我在firebug中检查时,我得到的是:POST是:
date=09%2F25%2F1986&title=Title&blogContent=
如您所见,blogContent为空.为什么是这样?
我正在将数据库中的名称,编号和公司插入.
我的表很简单:
id(primary key)
name
slideView
company
Run Code Online (Sandbox Code Playgroud)
如果传递给它的名称存在,我需要更新此信息,如果没有创建包含此数据的新行.我看过了,REPLACE INTO但我不认为这对我有用......因为我根本不接触ID.
我的代码是:
insertData($name,$count,$company);
function insertData($name, $count, $company) {
#Try/Catch statement to connect to DB, and insert data
try {
#DB username/password
$usernameDB = '****';
$passwordDB = '****';
#Create new PHP Database Object with the address, username, and password as parameters
$pdo = new PDO('mysql:host=localhost;dbname=*****', $usernameDB, $passwordDB);
#Set pdo attributes to handle errors
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
#assign the sth variable (sth means statement handle) to insert the data
$sth = $pdo->prepare("REPLACE INTO …Run Code Online (Sandbox Code Playgroud) 可能重复:
Javascript IE事件
IE8执行我的脚本时遇到问题.所有其他浏览器都很好.实际错误是:'tagName为null或不是对象'.我意识到我的脚本可能不是最好的,并且可以使用工作,但我真的需要它在IE8中工作.该脚本包含在document.ready jQuery函数中,我的jquery版本是1.5.2.我有一种感觉,主要问题与var target = ev.target;我不确定有关.
有问题的脚本部分是:
var hrNav = document.getElementById('hrNavListen');
var hrNav2 = document.getElementById('hrNavListenTwo');
var startButton = document.getElementById('startButton');
//Check to see if the user is on an iPad or iPhone
var isiPad = (navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i)) != null;
//If the user is on an iphone or ipad, use the touchstart event listener rather than click. Use click otherwise, or use onclick for IE users.
if (isiPad == true) {
hrNav.addEventListener('touchstart', highlight);
} else {
if(hrNav.addEventListener){ …Run Code Online (Sandbox Code Playgroud) 我是 SQL 新手,还无法正确执行此 SQL 查询。我目前有:
SELECT * FROM tableA
LEFT OUTER JOIN tableB
ON tableA.`full_name` = tableB.`full_name`
WHERE tableB.`id` IS NULL
Run Code Online (Sandbox Code Playgroud)
两个表都有人员记录,包括姓名和地址。我需要获取 tableA 中那些人的所有记录,而不是 tableB。下图基本上是我需要的:

问题是两个人可能有相同的名字,但地址不同。所以最终,我需要获取 tableA 中所有人的记录,不包括具有重复名称和地址的重复项。
每个表都有如下列:
id,full_name,first_name,last_name,title,phone,address,city,state,postal_code
Run Code Online (Sandbox Code Playgroud) 我从WCF服务获取一个字节数组,生成PDF并将其转换为字节数组.我需要能够获取字节数组并使用PHP或Javascript(或jQuery)获取该字节数组并将其转换回可下载的PDF.我更喜欢Javascript中的解决方案,但PHP也可以正常工作.
我用来获取PDF的代码是:
<?php
$userPDF = $_POST['username'];
$passPDF = $_POST['password'];
$idPDF = 'MO-N007175A';
//PDF Function
$data = array("id" => $idPDF, "username" => $userPDF, "password" => $passPDF);
$data_string = json_encode($data);
$ch = curl_init('http://********.com/******/v1/DealPdf');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_VERBOSE, 1 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
var_dump($result);
?>
Run Code Online (Sandbox Code Playgroud)
该var_dump($result);IS
string(1053285) "[37,80,68,70,45,49,46,54,10,37,211,244,204,225, ...
阵列持续了一段时间......所以我只提供了一小部分用于示例目的.
我从哪里开始从这个数组中获取PDF?
编辑 澄清 - WCF服务IS返回一个实际的PDF,只是一个字节数组.我需要在客户端计算机上将此字节数组保存为PDF.我使用过fwrite等等,但我必须遗漏一些东西,因为我看不到它有效.
另外 - 如果我使用fwrite,它输出文件在哪里? 编辑
我使用PHP从Web服务返回JSON.我能够获得JSON,解码它,并查看结果.但是,我需要能够按特定值对数组进行排序.我目前有:
// JSON URL which should be requested
$json_url = 'https://*******/maincategories';
// Initializing curl
$ch = curl_init( $json_url );
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
);
// Setting curl options
curl_setopt_array( $ch, $options );
// Getting results
$result = curl_exec($ch); // Getting JSON result string
$data = json_decode($result);
ksort($data, "Total");
print_r($data);
Run Code Online (Sandbox Code Playgroud)
这print_r($data);打印:
Array ( [0] => stdClass Object ( [Goal] => 10000000 [Name] => Rental [Total] => 500000 ) …Run Code Online (Sandbox Code Playgroud) 我有一个类似于这个的数组:
Array
(
[0] => stdClass Object
(
[Leasing] => 12939.74
[Name] => Jeremy
[Rental] => 0
[Sales] => 56603.13
[Total] => 69542.87
)
[1] => stdClass Object
(
[Leasing] => 0
[Name] => Shaun
[Rental] => 0
[Sales] => 58590
[Total] => 58590
)
[2] => stdClass Object
(
[Leasing] => 0
[Name] => Lindsay
[Rental] => 0
[Sales] => 22951.97
[Total] => 22951.97
)
[3] => stdClass Object
(
[Leasing] => 0
[Name] => Sally
[Rental] => 1200 …Run Code Online (Sandbox Code Playgroud)