1
jquery ajax call on focusout
CGuild1.com > Tips & Tricks > jquery ajax call on focusout

How to call ajax on every focus out in jquery

Call an ajax js on focusout if you have jQuery installed.

<script type="text/javascript">
    $('.l-row input[type="text"]').on('focusout', function() {
        $agents=$(this).closest('.l-row');
        var valu=$agents.attr('data-value');
        var item=$(this).val(); // here, this will be the input element that just fired a focusout event.

        alert(item);
        var page_id="<?=$page=basename($_SERVER['PHP_SELF']); ?>";
        $.ajax({
            url: '<?=base_url()?>record_edit',
            type: 'post',
            data: 'id='+valu+'&page_id='+page_id,
            success:function(data)
            {
                //alert(data);
            }
        });
    });
</script>

This will attach focusout event handlers for all the inputs with "type=text" in ide the div with class="l-row"

Origanally found it here at Stackoverflow.

©2024 CGuild1.com