0

cURL 通过来自 Ajax 的不同查询返回相同的结果。如果我在浏览器的 url 字段中复制查询,它会起作用并返回正确的结果。测试.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;

脚本.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
                });
4

0 回答 0