javascript - how to set a dynamic URL to the XHR POST parameter? -


note : please note question may silly i've begun client-side development. need make xhr post request dynamic link retrieved through jsonp. reasons doesn't work. post url "youtube_url_upload" becomes undefined.

  xhr.open("post", youtube_url_upload); 
here code snippet :

     var get_youtube_service_url ="http://video.example.com/youtubeupload?jsoncallback=?";        $.ajax({             type: "get",             url:  get_youtube_service_url,             datatype: "jsonp",             cache : false,             success: function(data) {                  // youtube             //  var y_url = data.url;              var token =  data.token;             var  youtube_url_upload = data.url + "?nexturl="+encodeuricomponent("http://selling.example.com/youtube.html");             calltoken(token);              uploadfile(youtube_url_upload);               }           });       var bytesuploaded = 0;       var bytestotal = 0; ...... 
  function uploadfile(youtube_url_upload) {        var xhr = new xmlhttprequest(youtube_url_upload);                 xhr.upload.addeventlistener("progress", uploadprogress, false);         xhr.addeventlistener("load", uploadcomplete, false);         xhr.addeventlistener("error", uploadfailed, false);         xhr.addeventlistener("abort", uploadcanceled, false);         xhr.open("post", youtube_url_upload);          xhr.send(fd);          intervaltimer = setinterval(updatetransferspeed, 500);       } ..... 

the success callback string "data", not object
it's may json use

$.parsejson ( data ) 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -

delphi - How to convert bitmaps to video? -