Przeszukaj pomoc

Unikaj oszustw związanych z pomocą.Nigdy nie będziemy prosić Cię o dzwonienie na numer telefonu, wysyłanie SMS-ów ani o udostępnianie danych osobowych. Zgłoś podejrzaną aktywność, korzystając z opcji „Zgłoś nadużycie”.

Więcej informacji

jQuery cross-domain ajax call

  • 5 odpowiedzi
  • 1 osoba ma ten problem
  • 11 wyświetleń
  • Ostatnia odpowiedź od ojm37

more options

I have the following jQuery ajax code that works fine in IE, Chrome and Opera. However, in Firefox it is aborted (calls remote computer but it says there's a "handshake problem").

$(document).ready(function () {

     jQuery.support.cors = true;      
        $.ajax({
           url: "tlscheck.site.com:10443/a/check",
           type: "GET",
           crossDomain: true,
           success: function (json) {
              UpdateDatabaseForTLSVersion(json);
           },
           error: function(jqXHR, status, strErr) {
              //alert("Error: " + status);
              //alert(strErr);
           }
        });      
  });

I already have the host headers Access-Control-Allow-Origin "*", etc set. And the server supports CORS (that's how IE and Chrome are getting there)...

Any ideas?

I have the following jQuery ajax code that works fine in IE, Chrome and Opera. However, in Firefox it is aborted (calls remote computer but it says there's a "handshake problem"). $(document).ready(function () { jQuery.support.cors = true; $.ajax({ url: "tlscheck.site.com:10443/a/check", type: "GET", crossDomain: true, success: function (json) { UpdateDatabaseForTLSVersion(json); }, error: function(jqXHR, status, strErr) { //alert("Error: " + status); //alert(strErr); } }); }); I already have the host headers Access-Control-Allow-Origin "*", etc set. And the server supports CORS (that's how IE and Chrome are getting there)... Any ideas?

Wszystkie odpowiedzi (5)

more options

Do server logs show a connection from Firefox, or nothing?

It's an unusual port number, and that raises the possibility of tripping over port banning. To test for that:

Create a new preference using about:config and explicitly allow the port number. Here's how:

(0) Select and copy the following preference name

network.security.ports.banned.override

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful.

(2) In the search box above the list, type or paste ports and pause while the list is filtered

If the above-listed preference exists:

(3) Double-click it and add a comma to the end of the list followed by the port number you need to allow. No spaces. Then click OK.

If the above-listed preference does not exist:

(4) right-click anywhere on the page and choose New > String

(5) In the preference name dialog, paste the name you coped and click OK

(6) In the preference value dialog, type in the port number you need to allow, then click OK.

Screen shot for illustration:

Any difference?

Obviously not practical for end users of your application, but hopefully this is only needed for testing.

more options

Thanks for the reply. Allowing that port did nothing.

I don't have server logs for this particular server since it's an open-source go program that is handling the requests... The request is getting to the server because it reports the "handshake problem"...

The error looks like this: date time handshale problem: &net.OpError{Op:"remote error", Net:"", Source:net.Addr(nil), Addre:net.Addr(nil), Err:0x30}

I find it really strange that IE, Chrome and Opera work fine but Firefox does not (in this case)...

Thanks, ojm

more options

Does the URL load normally in a Firefox tab, in other words, the problem only arises when requesting the page using XMLHttpRequest?

In that case, I think it's time to escalate the question to a more developer-oriented forum. This article suggests next steps for that: Where to go for developer support.

more options

Yes. The URL loads normally in a firefox tab and only has a problem when requesting the page with the jquery ajax request.

more options

Firefox now makes the call, but gets an error (permission denied) -- I've changed the jquery call to this (adding in jsonp stuff):

   $.ajax({
           url: "tlscheck.site.com:10443/a/check?callback=?",
           type: "GET",
          crossDomain: true,
          jsonp: "callback",
          jsonpCallback: 'myCallback',
          contentType: "application/json; charset=utf-8",
          success: function (json) {
              UpdateDatabaseForTLSVersion(json);
              //alert("Updated: " + JSON.stringify(json));
          },
          error: function(jqXHR, status, strErr) {
              var ErrJson = {"tls_version": "Error"};
              UpdateDatabaseForTLSVersion(ErrJson);
              //alert("Error: " + status);
              //alert(strErr);
           }
        });
   window.myCallback = function(data) {
     json = data;
   }

Had to create an if/then block around this as some other browsers need a few more parameters that firefox chokes on. BTW, I'm basically getting the same error from the Edge Browser (and IE11) on Windows 10. IE11 on Windows 8.1 works fine. Browser vendors REALLY need to come up with a standard way for developers to do this...

Thanks, Oj