NetworkError: Connection failure due to HTTP 0
<p>I am trying to pass values from my jQuery to my <code>duplicateFoldersAndFiles</code> function I have in GS, these values were retrieved by calling <code>generateFolderTree</code> function also on GS and it worked fine.</p>
<p>However, when I call <code>duplicateFoldersAndFiles</code>, I get an error:</p>
<blockquote>
<p>NetworkError: Connection failure due to HTTP 0</p>
</blockquote>
<p>and my values are also not getting passed. How can I remedy this?
Here's my code.</p>
<p>jquery</p>
<pre><code>&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
var destFolder = false;
var canClick = true;
var text;
var textDest;
$(function(){
$(&quot;#selectFolder&quot;).click(runMyFunction);
});
function runMyFunction(){
if(canClick){
google.script.run
.withSuccessHandler(successCallback)
.withFailureHandler(showError)
.generateFolderTree();
canClick = false;
}
}

function showError(error) {
    console.log(error);
    window.alert('An error has occurred, please try again.');
  }
  
  function onSuccess() {
  console.log( &quot;text &quot; + text + &quot; other &quot; + textDest);
  }
  
  function successCallback(returnedArray)
  {
    console.log(&quot;returnedArray&quot; + returnedArray);
    var folders = returnedArray;
   console.log(&quot;folders&quot; + folders);
    var i = 0;
    //row;
    for( i=0; i&lt;folders.length;i++)
    {
       console.log(&quot;i = &quot; + i);
   var row = $('&lt;p&gt;&lt;tr&gt;&lt;button class = &quot;selectedFolder&quot;&gt;' + folders[i] + '&lt;/button&gt;&lt;/tr&gt;&lt;/p&gt;');
    $(&quot;#source&quot;).append(row.html());
    }
  }
 
  $('#source').on('click', 'button.selectedFolder', function(){
  if (!destFolder){
   text = $(this).text();
  $('#sourceFolder').text(text);
  } 
  else{
   textDest = $(this).text();
  $('#destinationFolder').text(textDest);
  }
  });

$('#destFolder').on('click', function(){
  destFolder = true;
$('#source').empty();
//alert('boof');
google.script.run
.withSuccessHandler(successCallback)
.withFailureHandler(showError)
.generateFolderTree();
});
$('#copy').on('click', function(){
//alert('boof');
google.script.run
.withSuccessHandler(onSuccess)
.withFailureHandler(showError)
 
.duplicateFoldersAndFiles(text, textDest);
});
&lt;/script&gt;
</code></pre>
<p>code.gs</p>
<pre><code>function duplicateFoldersAndFiles(text, textDest) {
  var ui = SpreadsheetApp.getUi();
var mySource = text;
var myDestination = textDest;
ui.alert(mySource);
}
</code></pre>