0
我有一個$.ajax
在php中運行文件並傳遞一個變量(電子郵件地址)。該文件非常好,但xhr.status
是0
。HTTP狀態碼0可能是跨站點腳本?
這是代碼:
$.ajax({
type: 'POST',
url: 'file.php',
data: { email: destinatario },
complete: function(xhr,status){
$('#momentaneo, #force').remove();
alert(xhr.status);
if(xhr.status === 200){
alert('ok');
}
else{
alert('no');
}
}
});
這file.php
,獨立xhr.status
,做工精細而且將用戶添加到我的通訊。所以我不認爲這個文件是問題.. 它有「0755」權限文件,如果我用瀏覽器運行file.php
的URL沒有問題。
的問題是,xhr.status
是0
,我不明白爲什麼...... 我讀這可能是「跨站點腳本」,但我不知道,如果是不可能性在我的情況。我也試圖改變標籤form
在div
但沒有。
我還添加了file.php
:
<?php
include('wrapper.php');
$apikey = "76a21109637d7391d1e68e9680e6";
voxmail_init($apikey);
voxmail_user_subscribe(array('mail' => $_POST['email'],'privacy' => 1),$_SERVER['REMOTE_ADDR']);
$header = "Content-type: text/html";
header($header);
print('<b>ok</b>');
?>
voxmail是通訊服務的API(我敢肯定,101%,該API不是問題)
我希望你能幫幫我,謝謝了很多並對不起我的英文
控制檯中還有這個「Multiorigine blocked request(cross-origin):原始對應的標準不允許讀取遠程資源http://www.example.comfile.php。Motivo:header CORS」Access- Control-Allow-Origin「mancante」。 – Borja
@Borja你能告訴我們你的服務器端代碼處理這個請求嗎?也許您是否將客戶端重定向到另一個URL以響應此請求? – idbehold
@Borja沒關係,我看到你已經添加了服務器端代碼。 – idbehold