cURL使用来自Ajax的不同查询返回相同的结果。 如果我在浏览器的url字段中复制查询,它会工作并返回正确的结果。 test.php的
<?php
header("Content-type: text/html; Charset=iso-8859-1");
curl_setopt($c, CURLOPT_FRESH_CONNECT, 1); // don't use a cached version of the url
$query = $_GET['query'];
$source = $_GET['source'];
$startDate = $_GET['startDate'];
$endDate = $_GET['endDate'];
if($query != ""){ $query = '%20AND%20' . $query ;}
$req = '...:['. $startDate .'T00:00:00Z%20TO%20'. $endDate .'T00:00:00Z]%20AND%20origin:'. $source . $query;
$curl1 = curl_init($req);
curl_setopt($curl1,CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($curl1,CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($curl1);
echo $result;
的script.js
$.ajax({
url : 'test.php',
type: 'GET',
dataType: 'json',
cache:false,
data: {'query': query, 'source': source, 'startDate': startDate, 'endDate': endDate, 'interaction': interaction},
success: function(source){
data = source;
loadTable();
},
error: errorAjax
});