How to change the querystring when I submit my GET form using JQuery?

后端 未结 3 1288
抹茶落季
抹茶落季 2020-12-19 12:25

Suppose that I have a simple form in my page like this :

3条回答
  •  一整个雨季
    2020-12-19 13:03

    You need to prevent the default submit action from happening

    $(document).ready(function() {
        $("#form_search").submit(function(event) {
            event.preventDefault(); // <-- add this
            var querystring = rewrite_interval_qstring();
            // querystring equals "?price=100000,200000" -> exactly what I want !
    
            window.location.href = querystring; // <-- this should work.
        });
    });
    

提交回复
热议问题