javascript - Call same function on page load and when form submit -
$("#getlog").submit(function (e) { e.preventdefault(); $.ajax({ //some code }); }); <form id="getlog"> <input type="submit"> </form>
i want call function when page loads , when user presses submit button.
i have tried document.getelementbyid("getlog").submit()
on page load call function.
try defining separate function , call on load , on submit
function ajaxcall(){ $.ajax({ //some code }); } $(document).ready(function(){ ajaxcall(); }); $("#getlog").submit(function (e) { e.preventdefault(); ajaxcall(); });
hope help
Comments
Post a Comment