esponse 到预检请求未通过访问控制检查:没有"访问控制-允许-源"



嗨,我正在使用jquery ajax方法来获取登录令牌,但收到此消息

无法加载 https://login.salesforce.com/services/Soap/u/42.0?wsdl: 对预检请求的响应未通过访问控制检查:否 "访问控制允许源"标头存在于请求的上 资源。起源 'https://www.example.com

$(document).ready(function(){
//alert('blnk');
$.ajax({
headers: {
"Accept" :'application/json'   //If your header name has spaces or any other char not appropriate
},
url: 'https://login.salesforce.com/services/Soap/u/42.0?wsdl',
contentType: "application/json; charset=utf-8",
type: 'post',dataType: "post",data:JSON.stringify( {username  :'demo',  password  :'demo'}),
crossDomain: true, 
success: function(resuklt){
console.log(resuklt);  
}});
[enter image description here][1]
});

请使用...

dataType: 'jsonp',  //use jsonp data type in order to perform cross domain ajax
crossDomain: true,

在成功功能之前..

相关内容

最新更新