HTTP 状态代码 0 可能是跨站点脚本?
HTTP status code 0 is maybe Cross-site scripting?
我在 php 中有一个 $.ajax
运行 文件并传递一个变量(电子邮件和地址)。该文件工作得很好,但 xhr.status
是 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
我不明白为什么...
我读到可能是 "cross-site-scripting" 但我不知道我的情况是否可行。我也尝试更改 div
中的标签 form
,但什么也没有。
我还添加了 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 没有问题)
我希望你能帮助我,非常感谢,对不起我的英语
我认为问题在于当 status
作为完整回调中的第二个参数传递给您时,您正在检查 xhr.status
。试试这个:
$.ajax({
type: 'POST',
url: 'file.php',
data: { email: destinatario }
}).always(function(){
$('#momentaneo, #force').remove();
}).then(function(){
console.log.apply(console, arguments);
alert('ok');
}, function(){
console.warn.apply(console, arguments);
alert('no');
});
控制台语句仅用于调试目的,可以删除。
我在 php 中有一个 $.ajax
运行 文件并传递一个变量(电子邮件和地址)。该文件工作得很好,但 xhr.status
是 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
我不明白为什么...
我读到可能是 "cross-site-scripting" 但我不知道我的情况是否可行。我也尝试更改 div
中的标签 form
,但什么也没有。
我还添加了 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 没有问题)
我希望你能帮助我,非常感谢,对不起我的英语
我认为问题在于当 status
作为完整回调中的第二个参数传递给您时,您正在检查 xhr.status
。试试这个:
$.ajax({
type: 'POST',
url: 'file.php',
data: { email: destinatario }
}).always(function(){
$('#momentaneo, #force').remove();
}).then(function(){
console.log.apply(console, arguments);
alert('ok');
}, function(){
console.warn.apply(console, arguments);
alert('no');
});
控制台语句仅用于调试目的,可以删除。