Dailymotion API - CORS: Server has Access-Control-Allow-Origin: * but ajax request is not going through browser same-origin -


this possibly problem dailymotion api appears: see here: jquery ajax request being block because cross-origin

in above question, solution jsonp, not work here post request.

from test request outside browser, appears server accept cors requests, ajax requests consistently fail, no matter how fiddle options.

my ajax settings:

          type:"post",               //i tried without parameter           xhrfields: {               //i tried false               withcredentials: true            },           processdata: false,                //i tried correct content type of 'multipart/form-data',           contenttype: false,             //i tried enabled(and without)           //crossdomain:true, 

sample request outside browser (notice cors settings good)

 post /upload?uuid=21dddfd208868ec5ee38c0f641aa0a43 http/1.1  user-agent: curl/7.35.0  host: upload-01 . sv6 . dailymotion . com  accept: */*  content-length: 139  expect: 100-continue  content-type: multipart/form-data; boundary=------------------------5219277ca226e314    * done waiting 100-continue    http/1.1 200 ok  date: sun, 30 aug 2015 21:05:54 gmt  content-type: text/plain  transfer-encoding: chunked  connection: keep-alive * server xupload/2.2.6 not blacklisted  server: xupload/2.2.6  access-control-allow-origin: *  access-control-allow-headers: content-type, content-range, content-disposition, content-description, session-id  access-control-allow-methods: get, post 

ajax error:

    dailymotion object { readystate: 0, getresponseheader: .ajax/v.getresponseheader(), getallresponseheaders: .ajax/v.getallresponseheaders(), setrequestheader: .ajax/v.setrequestheader(), overridemimetype: .ajax/v.overridemimetype(), statuscode: .ajax/v.statuscode(), abort: .ajax/v.abort(), state: .deferred/d.state(), always: .deferred/d.always(), then: .deferred/d.then(), 10 more… } error exception { message: "", result: 2153644038, name: "", filename: "https://ajax.googleapis.com/ajax/li…", linenumber: 4, columnnumber: 0, inner: null, data: null, stack: ".send@/ajax-googleapis-com/a…" } dmupload.js:98:12     "dailymotion[object object]error[exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)"  location: "js frame :: ajax-googleapis-com/ajax/libs/jquery/2.1.4/jquery.min.js :: .send :: line 4"  data: no]" 

firebug error:

    cross-origin request blocked: same origin policy disallows reading remote resource @ https://upload-01.sv6.dailymotion.com/upload?uuid=6513ac948c1c71afdfca3be8d359d0a5&seal=12dc43863f90d931f63e6492cdb40a9e?access_token=dxgdwfqyx1gpvrxoubpaeqlfer5zq0hhcg. (reason: cors request failed). 

update: got options request go through, chucked jquery , used ajax, using code:

          var xhr = new xmlhttprequest();            xhr.open('post', myurl2, true);           xhr.setrequestheader('authorization', 'bearer ' + token);           xhr.setrequestheader('content-type', 'multipart/form-data');           //xhr.setrequestheader('x-upload-content-length', blob.size);          // xhr.setrequestheader('x-upload-content-type', blob.type);           xhr.onload = function(e) {             if (e.target.status < 400) {               var location = e.target.getresponseheader('location');             } else {               alert("err10")             }           };           xhr.onerror = function(e) {             alert("err1", e)               };           xhr.send({'file': blob}); 

enter image description here

update 2: able send post request, not able read response. thught still able use callback feature not matter, did not work. here explanatory screenshot , new code. enter image description here

        var fd4 = new formdata();         console.log(blob)         fd4.append("file", blob);            var xhr = new xmlhttprequest();            xhr.open('post', myurl2, true);           xhr.setrequestheader('content-type', 'multipart/form-data');           //xhr.withcredentials = true;           xhr.setrequestheader('content-length', blob.size);          // xhr.setrequestheader('x-upload-content-type', blob.type);           xhr.onload = function(e) {             console.log("headers", e.target.getallresponseheaders())             if (e.target.status < 400) {               var location = e.target.getresponseheader('location');               //sendfile_(blob, blobl.size, blob.type, myurl2);             } else {               alert("err10")             }           };           xhr.onerror = function(e) {             console.log("headers", e.target.getallresponseheaders())             alert("err1", e)           };           xhr.send(fd4); 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -