0
我正在尝试执行ajax请求以从服务器读取xml。我正在使用代理来执行此操作。如果我直接在浏览器中输入请求,它将返回正确的XML。当我使用我的代理时,它返回“无效参数”。任何想法?AJAX返回“无效参数”的请求,请求在没有代理的情况下工作
Proxy.PHP
<?php
$c = file_get_contents((urldecode($_REQUEST['u'])));
$content_type = 'Content-Type: text/plain';
for ($i = 0; $i < count($http_response_header); $i++) {
if (preg_match('/content-type/i',$http_response_header[$i])) {
$content_type = $http_response_header[$i];
}
}
if ($c) {
header($content_type);
echo $c;
}
else {
header("content-type: text/plain");
echo 'There was an error satisfying this request.';
}
?>
要求:
$.ajax({
type: "GET",
url: 'proxy.php?u=' + 'http://192.168.100.147:8080/thredds/sos/cfpoint/timeSeriesProfile-Ragged-MultipeStations-H.5.3/timeSeriesProfile-Ragged-MultipeStations-H.5.3.nc?request=GetObservation&service=SOS&version=1.0.0&responseFormat=text%2Fxml%3B%20subtype%3D%22om%2F1.0.0%22&offering=urn:tds:station.sos:Station1&procedure=urn:tds:station.sos:Station1&observedproperty=temperature&eventTime=1990-01-01T00:00:00Z/1990-01-01T00:00:00Z',
dataType: "xml",
success: parseSOSGetObs,
error: function() {alert("AJAX ERROR for " + capRequest);}
});
谢谢!