Sunday, August 18, 2013

Enable/Disable Button on Ajax Call Using Jquery


HTML CODE:

<input type="button" value="Search" id="btnsearch" />

JQUERY SCRIPT:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

        $("#btnsearch").click(function () {

            $("#btnsearch").attr("disabled", "disabled");//Disable button
            $("#btnsearch").prop('value', 'Fetching....'); //Change Text to "Fetching..."

            //Operation goes here...

            $("#btnsearch").removeAttr("disabled");//Enable button
            $("#btnsearch").prop('value', 'Search'); //Change Text to "Search"
           

        });

    });

</script>

No comments:
Write comments
Recommended Posts × +