0

完了時に送信する Jquery があります。そのため、送信が 2 回発生します。同じことを避ける方法はありますか?

以下はコード スニペットです。


クレーム読み込みのルートは次のようになります。

# 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呼び出しは>>>>

/views/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>
4

1 に答える 1