2018-06-26 23:39



I am trying to setup a youtube upload for one of my own projects. I am using the sample code from google that can be found here:

The script to upload videos works perfectly fine. My only problem is the following:

I would like to offer multiple areas for the upload or multiple uploads in other words.

There is the general file that contains the sign-in button and the video upload itself. This file will be loaded into a DIV-container via Ajax. Loading the file works fine as well. The only problem is, that the sign-in button wont show up if the file was being loaded via ajax.

It seems to me that i would have to initialize the api again but even after searching the web for hours i could not fint anything. All i know is, that the following code is loaded by the api automatically:

googleApiClientReady = function() {
    gapi.auth.init(function() {
        window.setTimeout(checkAuth, 1);

So i think i need to figure out a way, how to load that function again once the ajax-call is finished. I just can not figure out how. Every time i try to call this function the browser gives me a gapi.client error message.

Does anybody have experience with the youtube api? What am i doing wrong here? Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dqan70724 dqan70724 3年前

    The answer would be in this line:

    UploadVideo.prototype.handleUploadClicked = function() {
      $('#button').attr('disabled', true);

    If this function is called after uploading and getting the video data, it will disable the upload button. Just remove that line and you'll be able to upload multiple videos.

    Hope this helps.

    点赞 评论 复制链接分享