How to avoid or perform Cross domain $.get when using ISA

252 Views Asked by At

I have the ajax query

    var url = "http://ISAServer.domain.com/WebSite";

    $.ajax({
        url: url,
        success: function (data) {
            alert('Load Successful');
        },
        error: function (data) {
            alert('error');
            console.log(data);
            console.log(data.readyState);
            console.log(data.status);
            console.log(data.statusText);
            console.log(data.responseText);
        },
        dataType: 'json'
    });

The error callback is called. In order to go through ISA, I use an IPad. Using an IPad, the values returned are not very helpful.

  • [object Object]
  • 0
  • 0
  • error
  • ""

I am fairly sure the issue is a cross domain get request. ISA somehow should redirect me to

"http://internal.domain/WebSite"

But it fails. Things are fine when I do not go through ISA and also make a $.get request from the same domain (fails if I try cross domain, like localhost to server).

I am using ASP.NET MVC-3. I have been unsuccessful implementing relative URL's. They end up in the form

"http://servername/siteName/Controller/ControllerService?query"

When it should be

"http://servername/siteName/ControllerService?query"

So, unless you know how to fix that, relative URL's are not an option (and being we have to go through ISA I seriously doubt it would solve anything). I have a helper method which resolves the current path "http://servername/siteName".

Any tips, ideas suggestions?

1

There are 1 best solutions below

0
Thomas Thorogood On BEST ANSWER

You can't perform cross-domain ajax requests. Well, there are ways to do it, but the built-in library doesn't allow for it for security reasons.

http://www.ajax-cross-domain.com/ provides a method to do this. I can't vouch for it, as I've never tried it, though.

From the URL above, though: "In client-side javascript, this functionality is not present due to the Same Origin Policy. Though this policy is necessary for a robust security model, programmers are often handicapped in their wish to send and retrieve requests to remote servers."