Preflight of cross domain Ajax with custom header (using jquery) always getting cancelled

I am trying to make a cross domain POST with custom headers, but the preflight always getting cancelled (That's the word in Chrome's "Inspect Element" panel >> "Network" label), and I cannot tell whether it was cancelled by the browser or by jQuery. Code is:

var request = $.ajax({
    'type'        : 'POST',
    'crossDomain' : true,
    'url'         : 'https://host.domain/some_path',
    'data'        : {'some_key': 'some_value'},
    'headers'     : {
        'Authorization'        : 'CUSTOM-METHOD credential_id:credential_secret',
        'X-Some-Custom-Header' : '2013-05-02'
    }
})
.done(function(blah){blah})
.fail(function(blah){blah});
  • If I remove the headers object, or set it to {}, then the request can be made successfully.
  • If I remove the Authorization header, the preflight will still be cancelled.

I don't think it's server-side issue, because there is nothing about the OPTIONS request method in server's log. I think the preflight request was never been made.

So, any idea?

Thanks in advance.

Answers


Figured it out: it's a problem with the credential used in HTTPS, nothing to do with the codes. I generated the server credential myself, need to tell the browser to trust the credential.


Need Your Help

IllegalStateException Java Google Maps marker

java android json google-maps

I am trying to create markers on google maps, based on if the plane has departed yet. I have checked and everything works okay until it tries to create the planes.

Validate for a valid SQL string

c# .net sql

Is there a way (or existing library, not necessarily built into .NET) in C# that performs simple SQL string validation?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.