Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


ajax context option


ajax context option  using -'jquery,coldfusion'

Episode 11 of the yayQuery podcast mentions the $.ajax context option.
How would I use this option in the success callback?
What I'm currently doing is passing my input parameters back to the success callback so that I can animate the id that was called after success/error.
If I use the context option, then perhaps I don't have to pass the parameters back from the called routine.

In this example, I pass STATEID back to the success field so that the state is removed from the DOM once it's been deleted from the database:

$('td.delete').click(function() {
    var confirm = window.confirm('Are you sure?');
    if (confirm) {
        var StateID = $(this).parents('tr').attr('id');
        $.ajax({
            url: 'Remote/State.cfc'
            ,data: {
                method:'Delete'
                ,'StateID':StateID
            }
            ,success: function(result){
                if (result.MSG == '') {
                    $('#' + result.STATEID).remove();
                } else {
                    $('#msg').text(result.MSG).addClass('err');;
                };
            }
        });
    }
});

    

asked Oct 19, 2015 by atulpariharmca
0 votes
2 views



Related Hot Questions



Government Jobs Opening


...