ajax jquery cross domain issue

I am writing a ajax jquery to call wcf and have following error in chrome. IE is working fine. how can I fix it in jquery?

The 'Access-Control-Allow-Origin' header has a value


that is not equal to the supplied origin. Origin

'http://pq.abc.com' is therefore not allowed access.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The 'Access-Control-Allow-Origin' header should NOT contain anything after the domain name.

It should be this:

NOT this:
ITsolutionWizardAuthor Commented:
I need to pass query string
You can still pass the query string in the script.  You should NOT pass the query string in the header.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ITsolutionWizardAuthor Commented:
I do the following. And I do not think I pass it to the header.
Or you have any ideas how to fix with following codes.
Again, the codes working in IE. not in Chrome.

function GetModelList(divisCode)
      var customerNo = "315217";            
        var GetModelListJSon = "http://clientaccesstest.abc/GetModel";            
        $(document).ready(function () {
                cache: false,
                type: "GET",
                async: false,
                dataType: "json",
                contentType: 'text/plain',
                url: GetModelListJSon + encodeURIComponent("(011,115217)"),
                success: function (data) {
                    if (data == null)
                    resultObj = jQuery.parseJSON(data);
                    if (resultObj.Status != 'Failed') {
                error: function (xhr,status,error) {
                    alert(xhr.responseText + " : error GetModelListJSon");
You don't need to change the JavaScript/jQuery code!

You need to change the code on the server.  Depending on your setup, you might need to use .htaccess or PHP or ASP.NET or some other server-side language to change the header.
ITsolutionWizardAuthor Commented:
the service is wcf and we already added the header to codes and iis.
Well then wcf or IIS needs to be changed so that the header returned is this

NOT this:
ITsolutionWizardAuthor Commented:
I do not know what you mean. Please show me example.
Do you know what code or setting is creating the 'Access-Control-Allow-Origin' header?
ITsolutionWizardAuthor Commented:
    <modules runAllManagedModulesForAllRequests="true"/>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
        <add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS" />
ITsolutionWizardAuthor Commented:
In chrome, I can see status is 200 and response value showing up. But I keep getting this

The 'Access-Control-Allow-Origin' header has a value 'http://pq.abc.com?divCode=31' that is not equal to the supplied origin. Origin 'http://pq.jvc.com' is therefore not allowed access.
Would you post a screenshot of the header response as you see it in Chrome?
ITsolutionWizardAuthor Commented:
see attached
Thanks, I want to see what is on the network tab.  See attached.
ITsolutionWizardAuthor Commented:
What hi expect to see
I want to see all of the response headers returned by this URL:

I cannot test it myself because it is password protected.
ITsolutionWizardAuthor Commented:
see attached
The image shows that 13 Response Headers are returned.  

Access-Control-Allow-Origin: http://pq.abc.com

I see that you have added something to your web.config file to create an "Access-Control-Allow-Origin" header however it is not taking effect.  I am not an IIS expert.  I recomend that you post a new question in the IIS and ASP.NET topic areas asking how to get that header there.  If you include an image and a link to this question that should be able to help.

Good luck!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.