C# jQuery AJAX beforeSend在Firefox浏览器中失败

C# jQuery AJAX beforeSend在Firefox浏览器中失败,c#,ajax,rest,jquery,C#,Ajax,Rest,Jquery,我在AJAX jQuery中使用beforeSend在REST服务中传递头值。 头值在Internet Explorer 8中传递良好。但是Firefox中不会传递头值,也不会调用服务 这是我的密码: var postCall = function () { $.support.cors = true; var HFAssociateRefId = document.getElementById('MainContent_HFAssociateRefId').value; var Input =

我在AJAX jQuery中使用beforeSend在REST服务中传递头值。 头值在Internet Explorer 8中传递良好。但是Firefox中不会传递头值,也不会调用服务

这是我的密码:

var postCall = function () {
$.support.cors = true;
var HFAssociateRefId = document.getElementById('MainContent_HFAssociateRefId').value;
var Input = {
     AssociateRefId: HFAssociateRefId
 };       
 alert(JSON.stringify(Input));
 var url = document.URL;
 var currentdate = new Date();
 var datetime = (currentdate.getMonth() + 1) + "/"
 + currentdate.getDate() + "/"
 + currentdate.getFullYear() + " "
 + currentdate.getHours() + ":"
 + currentdate.getMinutes() + ":"
 + currentdate.getSeconds();
 $.ajax({
       type: "POST",
       headers: { Accept: "text/plain; charset=utf-8", "Content-Type": "text/plain; charset=utf-8"
                },
       beforeSend: function (xhr, settings) {
       xhr.setRequestHeader("Date", datetime);
       xhr.setRequestHeader("URL", url);
                },
       url: "http://localhost:40680/LinkService.svc/TokenInsertion",
       data: JSON.stringify(Input),
       contentType: "application/json",
       dataType: "json",
       success: function (response) {
       alert(response);
                },
       error: function (xhr, status, error) {           
       alert(status);
                },              
});
我还尝试将xhr作为新的XMLHttpRequest调用,如本文所述。
但它在Firefox中不起作用
提前谢谢

第一个问题是:

type: "post",
data: JSON.stringify(Input), <=== this is fail
correct is: data:{data:JSON.stringify(Input)}, 
recuest to $_POST['data']; is better if using arrays...
类型:“post”,
数据:JSON.stringify(输入)**

第一个问题是:

type: "post",
data: JSON.stringify(Input), <=== this is fail
correct is: data:{data:JSON.stringify(Input)}, 
recuest to $_POST['data']; is better if using arrays...
类型:“post”,
数据:JSON.stringify(输入)**

Firefox似乎不尊重标题
日期
。它正在发送标题
URL
。我找不到任何资源来解释这种行为

作为解决方案,您可以将标题
Date
重命名为其他名称

铬也表现出同样的行为

经进一步调查,它看起来像是按照标准的行为。如果标题是下列标题之一的不区分大小写匹配项,请查看标题为
的部分,终止这些步骤:


同样的问题也被问到了。

看起来Firefox不尊重标题
日期。它正在发送标题
URL
。我找不到任何资源来解释这种行为

作为解决方案,您可以将标题
Date
重命名为其他名称

铬也表现出同样的行为

经进一步调查,它看起来像是按照标准的行为。如果标题是下列标题之一的不区分大小写匹配项,请查看标题为
的部分,终止这些步骤:



同样的问题也被问到了。

请参阅。Firefox和Chrome从不接受添加新的自定义标题,因为它违反了浏览器安全规则。

请参阅。Firefox和Chrome从不接受添加新的自定义标题,因为它违反了浏览器安全规则。

beforeSend函数中添加警报
并测试它,它是否工作?@Rohan Kumar是的,警报值出现在beforeSend函数中。但是标题值没有传递。如果它不起作用,那么你可以在
数据
@Rohan Kumar中传递
数据和url
。如果我通过数据传递值,那么我需要在我的表中添加额外的列。在firefox中
日期
标题不起作用,但它正在发送
url
,你能确认吗?在beforeSend函数中添加一个警报并测试它,它是否工作?@Rohan Kumar是的,警报值出现在beforeSend函数中。但是标题值没有传递。如果它不起作用,那么你可以在
数据
@Rohan Kumar中传递
数据和url
。如果我通过数据传递值,那么我需要在我的表中添加额外的列。在firefox中
日期
标题不起作用,但它正在发送
url
,你能确认一下吗?我把日期变量改成了字符串。但它仍然传递头值。@kk1076它传递还是不传递它是否发送ajax请求?如果是,您可以在Firefox中使用浏览器的dev工具栏共享标题,ajax请求不会调用该服务。它不工作。我将日期变量更改为字符串。但它仍然传递头值。@kk1076它传递还是不传递它是否发送ajax请求?如果是,您可以在Firefox中使用浏览器的dev工具栏共享标题,ajax请求不会调用该服务。它不起作用。使用数据:{data:JSON.stringify(Input)}在IE8和Firefox中抛出错误请求使用数据:{data:JSON.stringify(Input)}在IE8和Firefox中抛出错误请求
<?php 
if(isset($_GET['datos'])){
$names  = array('john doe', 'JANE doe');
$ids    = array('123', $datos);

$data['names'] = $names;
$data['ids'] = $ids;


    echo json_encode($data);
}else{
    $error  =   array('error','No se recibieron metodos');
    $error  =   array('messeng','Method need chain test to Get');
    echo json_encode($error);
}
?>