0

我正在尝试调用用 PHP 开发的 REST API。我的 Titanium 代码非常简单。

var url = "http://www.sample.com";
    var client = Ti.Network.createHTTPClient(
    {
        // function called when the response data is available
        onload : function(e) 
        {
            Ti.API.info("Received text: " + this.responseText);
            alert('success');
        }
    });
    // Prepare the connection.
    client.open('GET', url,true);
    // Send the request.
    client.send();

我收到如下错误

[INFO] :   Received text: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[ERROR] :  was encountered while trying to use an ErrorDocument to handle the request.</p>
[INFO] :   <html><head>
[INFO] :   <title>403 Forbidden</title>
[INFO] :   </head><body>
[INFO] :   <h1>Forbidden</h1>
[INFO] :   <p>You don't have permission to access /
[INFO] :   on this server.</p>
[INFO] :   <p>Additionally, a 404 Not Found
[ERROR] :  <hr>
[ERROR] :  <address>Apache Server at www.sample.com Port 80</address>
[ERROR] :  </body></html>

我认为这与参数Access-Control-Allow-Origin有关,我将该参数更改为*,但它没有用。更改 ACAO 参数后,我可以从普通的 HTML + JS 代码调用 API。请帮忙。感谢和问候阿布舍克

4

0 回答 0