Quick Jquery: How to set context in $.ajax()

Share

Today working on a simple ajax jquery call, I was searching for setting context in ajax function suddenly one my javascript master came and wrote a code below, and it was done.

Its look like this:

         $('#click_me').function(){
            $.ajax({
               type: 'POST',
               data: 'value=34',
               context: $(this),
               success: function(resp){
                            $(this).next().html(resp);
                          }
             });
         });

And its all done!

  • September 11, 2010
8 Best Free Stock Video Websites for Tiktok, Reels, and Shorts Top 5 PHP Frameworks: Fast and Secure