Forum Discussion

futurehunter's avatar
futurehunter
Copper Contributor
Aug 08, 2021

how to avoid page reload in $(document).ready(function()

Hi Team,

 

After dropdown changevent completion page gets reloaded everytime. I want to stop after function execution. Kindly help.

 

<script type="text/javascript">

$( document ).ready(function()
{
alert('page load...');
$('select[id^="ctl00_ctl04_ctl00_ddlCrossWebLookupColumn"]').change(function()
{
alert('dropdown change event called');
functionTest();
});

 

});

function functionTest()
{
alert('change event function called...');
}

</script>

  • Vedran_Loani's avatar
    Vedran_Loani
    Copper Contributor
    Your code should not reload the page, Do you get the "page load..." message twice?

    Which browser are you using?

    preventDefault() might help, change $('select[id^="ctl00_ctl04_ctl00_ddlCrossWebLookupColumn"]').change to

    $('select[id^="ctl00_ctl04_ctl00_ddlCrossWebLookupColumn"]').change(function(e)
    {
    alert('dropdown change event called');
    functionTest();
    e.preventDefault();
    });

    Does the page reload with e.preventDefault()?

Resources