CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2016

    How to avoid the error ' No 'Access-Control-Allow-Origin' header' on an Ajax call

    My code below is :

    function getTicket() {
    	try {
    	alert("Get Ticket")
    	var tableauInfo = {
                username: "xxxxxxxx",
    	var dashboardResourceURL = "https://analytics.xxxxxxx/trusted/##TOKEN##/t/POC1/views/ExampleVis/Dashboard1?:iid=1"
    	var resourceURL = "https://analytics.xxxxxxxxxxx/trusted"
    		 	method: 'POST',   
    		 	url: resourceURL,
                data: JSON.stringify(tableauInfo),
                dataType: 'html',
                contentType:'application/x-www-form-urlencoded; charset=UTF-8',
                crossDomain: true,
                .success(function (result) {
                	$('#tokenurl').src= dashboardResourceURL;
                	console.log('failed!! ', data);
                    $('#getTicket').html("Error retrieving ticket from Tableau server");
                  console.log('an unforseen error occurred; it is ', err);
    I'm performing a client side request to hit the server and get a token and get the response object of token and repost the dynamic token to server to get the image on the browser

    I'm getting an error:
    No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

    Please suggest how to get rid of this error.
    Thanks in advance.
    Last edited by 2kaud; December 19th, 2016 at 12:41 PM.

  2. #2
    Join Date
    May 2002

    Re: How to avoid the error ' No 'Access-Control-Allow-Origin' header' on an Ajax call

    The issue is a server security setting that does not allow AJAX requests from other domains. Since the script running is not locationed on the same host/domain as the query page, it will not work. Only way around that is if you control the server being queried. Then you can turn on cross origin access.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width