php - esponse to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'

457

hi i am using jquery ajax method to get accces to login token but getting this message

Failed to load https://login.salesforce.com/services/Soap/u/42.0?wsdl: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '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]
    });
263

Answer

Solution:

Please use ...

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

before succes function..

People are also looking for solutions to the problem: php - How to make cart & checkout page calculation in opencart

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.