My javascript code looks like below :
function copysave(){
    dojo.io.iframe.send({
    form:dojo.byId("formId"),
    method: "POST",
    //handleAs: "html",
    encoding : "utf-8",
    url :"/CopyReplace/copysavefirst",
    load: function(response) {
        txtResponse = response;
        alert("respone: "+txtResponse);
        console.log(" success : txtResponse"+txtResponse)
    },
    error: function(error, ioArgs) {
        console.log("bulkcopy() ERROR :: " + error);
        console.log("bulkcopy() ioArgs :: " + ioArgs);
        return error;
    }
  });
}
My Html looks like below :
<form enctype="multipart/form-data" id="formId" method="">
<button name="save" id="submitValues" value="Finish" onclick="copysave()" >Finish</button>
If I click on finish, I can see /CopyReplace/copysavefirst hitting the server two times. 
Could some one please tell me what to do to call only once? 
Also, it is going to the error section. 
 
    