jQuery page redirect after submit the form

后端 未结 5 1195
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 22:36

I have a form like this

5条回答
  •  盖世英雄少女心
    2021-01-13 22:41

    I did it this way:

    html:

                        
                            
                        
    

    Javascript:

    function searchItem() {
    
        $.ajax({
            url: urlDomain + "pricelist/?itemName=" + $("#itemName").val(),
            type: "GET",
            headers: {"Accept": "application/json", "Content-Type": "application/json"},
            success: function(data) {
                // do your work on success and then,
                location.href = "path/to/next/Page/To/Display.html";
            },
            error: function() {
                alert("error");
            }
        });
    }
    

    I wrote above code for getting values from server, but you can change jQuery "Type" parameter to "POST" and add "data" parameter with its values you want to be sent to server.

    Hope it helps you...

提交回复
热议问题