I have a aspx page and a js file, am accessing the js file for some functions, say for example I have some autocomplete boxes in my aspx page and for that am accessing the js file for every autocomplete box, and finally when I click the save button, the saveFunction in my js file should be fired, for this I just made my Save button as simple html button as
<button type="button" onclick="saveRecords()">Save</button>
at the end of my aspx page am calling the js file as
<script type="text/javascript">
$(document).ready(function () {
pageInit();
});
and in the pageInit of my js file I refer my saveRecords function as
function pageInit() {
saveRecords();
}
the problem here is whenever I run my application the saveRecords function is hitting first…..how can I avoid this, and call this function only when I hit Save button…can anyone help me here….
If you don’t want to call
saveRecordswhen the page initializes, you should remove the call tosaveRecordsin thepageInitfunction.