为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

jQuery cross-domain ajax call

  • 5 个回答
  • 1 人有此问题
  • 11 次查看
  • 最后回复者为 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?

所有回复 (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