Jsp ajax call using jquery

前端 未结 2 413
无人及你
无人及你 2021-02-08 13:03

I have this code snippet where I am passing data to another jsp file.

Javascript

$(document).ready(function() {
    $(\"#click\").click(         


        
2条回答
  •  有刺的猬
    2021-02-08 13:27

    $(document).ready(function () {
        $("#click").click(function () {
            name = $("#name").val();
            age = $("#age").val();
            $.ajax({
                type: "POST",
                url: "pageTwo.jsp",
                data: "{'name':'" + name + "','age':'" + age + "'}",
                contentType: "application/json",
                async: false,
                success: function (data) {
                    $("#response").html(data.d);
                }
            });
        });
    });
    

提交回复
热议问题