Jsp ajax call using jquery

前端 未结 2 414
无人及你
无人及你 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);
                }
            });
        });
    });
    
    0 讨论(0)
  • 2021-02-08 13:36
    $("#click").click(function(e) {
        // e.preventDefault();
        ...
        return false;
    });
    

    and of course install firebug or use chrome default developer tools (f12). open console and run the code.

    0 讨论(0)
提交回复
热议问题