7

I'm stumped on an issue I'm having with an HTTPS Ajax call in IE only. IE seems to think I'm making a crossdomain request, but I'm not. The following code is called from the page https://mydomain/customer_profile.php:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

This request works just fine in every browser except IE. In IE, the error function returns "Error: Access is denied". Like I said, I'm completely stumped on this, so any insight or ideas would be great.

Jim D
  • 988
  • 10
  • 18
  • 1
    Try it without the `https://mydomain`. So, try with the URL as "/ajax/retrieve_transaction_details.php". – Mike Lentini Jan 27 '12 at 16:18
  • I have tried this. For whatever reason, if I don't specify an absolute path, other browsers then try to make the request over HTTP, thus breaking it in those too. – Jim D Jan 27 '12 at 16:20
  • Perhaps add a check for browsers which will follow a path if they use IE for compatibility and if they use any other browser then forward it to the code u already have working. – HenryGuy Jan 27 '12 at 16:47
  • Firstly, verify that you don't have it set up so that you loaded the page from `http://www.mydomain` and your AJAX references just `http://mydomain` or vice versa - this might be considered X-domain. Next, try `://mydomain/ajax/retrieve_transaction_details.php` without `http`/`s`. – DaveRandom Jan 27 '12 at 16:47

2 Answers2

3

I guess you are using the <base> tag inside the head section of your HTML; right?

If it is pointing to http instead of https, that would break IE.

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
Nate
  • 1,303
  • 8
  • 12
  • Wow, that would in fact be it. I completely forgot I had thrown that tag in my header template. Funny it only broke it in IE, but I guess that's IE for ya. Thanks! – Jim D Jan 31 '12 at 19:45
2

try setting crossDomain to true in your request like this:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    crossDomain: true,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

this should allow you to make the request regardless of whether it is cross-domain or not.

Phil W
  • 549
  • 2
  • 5
  • take a look at this post: http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error – Phil W Jan 27 '12 at 16:56