0
我正在向我的服务器发送认证请求,但在此之前我需要设置两种类型的标头。 (例如,内容类型和安全密钥)。请让我知道如何使用jQuery,Ajax设置这些自定义标题。 此外,是否有可能使用jQuery,Ajax来验证用户,还是我们需要使用脚本语言lang(例如PHP,JSP .....) 我试过以下。有没有什么办法可以在jQuery中设置多个自定义标头Ajax
url: "https://mysite",
type: "POST",
dataType: 'json',
contentType: 'application/json',
headers: { 'MYKey': 'ABCDEFGHIJKLMNOPQRST' },
data: JSON.stringify(data),
async: false,
crossDomain: true,
success:function (data) {
//var obj=jQuery.parseJSON(data);
//alert(data+"");
console.log(data);
alert(JSON.stringify(data)+" Success");
//JSON.parse(t);
},
error:function(data){
//var obj1=jQuery.parseJSON(data);
//var x= JSON.parse("two"+data);
//alert(obj1.uid+"vinay");
console.log(data);
alert(JSON.stringify(data)+" error");
}
让我知道这种方法是否可以通过https进行身份验证?
我收到以下错误 { “readyState的” 0 “responseText的”: “”, “状态”:0, “状态文本”: “错误”} Regds
我也试过这个,但它给出了这样的回复:“readyState”:0,“responseText”:“”,“status”:0,“statusText”:“error”} – user2849371