Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using ajax for web Api calling from C#.net . When i call the ajax function i geting this error 

<pre>Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:49956' is therefore not allowed access


and my ajax funcion is

$.ajax({
                        url: 'https://xxx.xxx.com/external/xx/token',
                        type: 'POST',
                        data: RequestBody,
                        Accept: 'Application/Json',
                        contentType: 'Application/Json',
                        headers: {
                            'Authorization':'Integration mOB33m0='
                        },
                        beforeSend: function(request) {
                            request.setRequestHeader("Authorization", "Integration bWE3Om0=");
                        },
                        success: function (data) {
                            debugger;
                           
                        },
                        error: function (xhr, textStatus, errorThrown) {
                            debugger;
                          

                        }

                    });


But i run the API through Fiddler the APi works very good. That means API is good there is a problem some were in my code . Where i am wrong .

What I have tried:

search in google but no appropriate answer i found.
Posted
Comments
F-ES Sitecore 11-Jul-18 10:52am    
You googled this error message and found no results? Seriously? It's one of the most frequently asked questions and the solutions are well documented.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900