I need a simple AJAX code to stay in same jsp page after i click submit button.It should not refresh the page. I have researched a lot. But didnt get a simple one.Please help
1条回答 默认 最新
MAO-EYE 2017-07-21 07:37关注you can find a simple form submit example in this link
you can add a button
<button id='submit-btn'>Submit</button>and make ajax call on click of that as in below code.$('#submit-btn').on('click', function (e) { var postData = $('#ajaxform').serializeArray(); var formURL = $('#ajaxform').attr("action"); $.ajax( { url : formURL, type: "POST", data : postData, success:function(data, textStatus, jqXHR) { //data: return data from server }, error: function(jqXHR, textStatus, errorThrown) { //if fails } }); });解决 无用评论 打赏 举报