Jquery play框架避免双重提交

Jquery play框架避免双重提交,jquery,playframework,Jquery,Playframework,我有一个Jquery,它在完成时提交,因此提交发生了两次。有没有办法避免同样的情况 下面是代码片段 我的索赔装载路线如下所示 # Claim Loading for Historical Claims GET /claimLoading controllers.ClaimLoading.form POST /claimLoading controllers.ClaimLoading.submit 在我的控制器中,提交如图所示 /**

我有一个Jquery,它在完成时提交,因此提交发生了两次。有没有办法避免同样的情况

下面是代码片段


我的索赔装载路线如下所示

# Claim Loading for Historical Claims
GET     /claimLoading            controllers.ClaimLoading.form
POST    /claimLoading            controllers.ClaimLoading.submit

在我的控制器中,提交如图所示

/**
 * Handle form submission.
 */
def submit = Action { implicit request =>
claimLoadingForm.bindFromRequest.fold(
  // Form has errors, redisplay it
  errors => {
    Logger.info("Some error occurred before calling the service")
    BadRequest(html.claimloading.form(errors))
  },
  claimLoading => {
    // Invoke the LoadCSVorXML2Mongo service from here
    claimsLoadingService.loadCSVOrXMLClaimToDatabase(claimLoading.claimLoadingPath)

    val resultSummary  = claimsLoadingService.retrieveSummaryInfo
    // We got a valid ClaimLoading value, display the summary
    Ok(html.claimloading.summary(claimLoading, Json.prettyPrint(resultSummary)))
  }

)
}

从按钮单击的Jquery调用是>>>>

/视图/claimloading/form.scala.html

<input type="button" class="btn primary" id="claimsLoadButton"  value="Invoke Claim Loading">


claimloading下form.scala中的Jquery为>>>

<script type="text/javascript"  xmlns="http://www.w3.org/1999/html">

$(document).ready( function () {
    $("#claimsLoadButton").click(function () {
        createLoadingModal();
        showLoader(true);
        $.ajax({
            url: "/claimLoading",
            type: "POST",
           data: $("#claimLoadingForm").serialize(), // serializes the form's elements.
            dataType:"json",
            success: function (data) {
                showLoader(false);
            },
            error: function (jqXHR, textStatus, errorThrown) {
            },
            complete: function (data) {

                submitClaimsLoading();
            }
        });
    });
});

function submitClaimsLoading()
{
    $("#claimLoadingForm").submit();
    showLoader(false);
}

</script>

$(文档).ready(函数(){
$(“#claimsLoadButton”)。单击(函数(){
createLoadingModal();
showLoader(真);
$.ajax({
url:“/claimLoading”,
类型:“POST”,
数据:$(“#claimLoadingForm”).serialize(),//序列化表单的元素。
数据类型:“json”,
成功:功能(数据){
showLoader(假);
},
错误:函数(jqXHR、textStatus、errorshown){
},
完成:功能(数据){
submitClaimsLoading();
}
});
});
});
函数submitClaimsLoading()
{
$(“#claimLoadingForm”).submit();
showLoader(假);
}
用于在单击按钮时停止表单提交

$(document).ready(function (event) {
    event.preventDefault(); //add this here
    $("#claimsLoadButton").click(function () {
        createLoadingModal();
        showLoader(true);
        $.ajax({
            url: "/claimLoading",
            type: "POST",
            data: $("#claimLoadingForm").serialize(), // serializes the form's elements.
            dataType: "json",
            success: function (data) {
                showLoader(false);
            },
            error: function (jqXHR, textStatus, errorThrown) {},
            complete: function (data) {

                submitClaimsLoading();
            }
        });
    });
});