in the development of the page, sometimes to reuse the form of data, and asynchronous requests submitted to other links, this time can use jquery to modify the form's action value (remember to change back after use), and call the Submit method, Of course, the link action or controller method in the background must return a value of type void, otherwise a page jump will occur, return NULL to display a blank page, cannot implement an asynchronous call. Alternatively, you can use another way to commit, serialize the form, and then submit it with jquery Ajax, but process the returned information. Directly on the code: (1) jquery Changes the form property
$ (". Exportbrandsort"). On (' click ', Function () { var url = contextpath+ "/brand/exportbrandsort"; $ (' #searchform '). attr (' action ', URL); $ (' #searchform '). Submit (); Restore Action value url = contextpath+ "/brand/getbrand"; $ (' #searchform '). attr (' action ', URL); });
(2) Ajax submission method
$ (". Exportbrandsort"). On (' click ', Function () { var url = contextpath+ "/brand/exportbrandsort"; var data= $ (' #searchform '). Serialize (); $.ajax ({ type: ' GET ', url:url, data:data, success:function (Retjson) { } }); });
Use jquery to reuse form forms and submit them asynchronously to another action