jQuery.load只能在同一服务器/位置上运行?

时间:2016-05-24 11:04:42

标签: php jquery

我有一个非常基本的html文件,其中包含加载php文件的jquery脚本:

<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8">

    <title>Title</title>
    <meta name="description" content="Hello World!">
    <meta name="author">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>

    <!-- <link rel="stylesheet" href="css/styles.css?v=1.0"> -->
</head>

<body>    
    <div id="dashboard-container">
    </div>    
    <!-- <script src="js/scripts.js"></script> -->
    <script>
        $(document).ready(function(){
            $("#dashboard-container").load('http://example.com/data/access_data.php');
        });
    </script>
</body>
</html>

php文件正在访问SOAP-api并回显一些数据:

$client = new SoapClient('http://www.e-conomic.com/secure/api1/EconomicWebService.asmx?wsdl');

$getAllOrders = $client->Order_GetAll();
$array = json_decode(json_encode($getAllOrders), True);

foreach($array as $data) {
    $array2 =  $data["OrderHandle"];
};

$sliced = array_slice($array2, -20, 20, true);
$reversed = array_reverse($sliced);

foreach ($reversed as $data) {
    $handle = $data["Id"];
    $getOrders = $client->Order_GetData(array(
        'entityHandle' => array(
            'Id' => "$handle"
        )
    ));
    $getOrders = json_decode(json_encode($getOrders), True);
    foreach ($getOrders as $data) {
        echo $data['DebtorName'] . ", " . $data['Heading'] . ", " . $data['IsSent'] . ", " . $data['DeliveryDate'] . ", " . $data['NetAmount'] . "<br>";
    }
};

只要文件位于同一位置,效果就会很好。这意味着两者都在localhost或同一个在线服务器上。但这并不意味着我需要能够从远程服务器加载文件。如果我尝试使用此代码执行此操作,则不会再加载php文件。即使该文件可以在链接的地址上访问。这让我感到惊讶,任何人都有解释和解决方案吗?

0 个答案:

没有答案