How to Intecept a jquery.ajax call with confirm ()

How to Intecept a jquery.ajax call with confirm ()

public Coding Tips  Comment Now

[30 December 2019] public Public


Ajax is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.

Below code helps you to give the condition, before running the ajax code. This is widely used to prevent the existing content to not get deleted.

$('.removeItem').click(function (event)
{ if (confirm('Are you sure you want to delete this?'))
{ $.ajax({ url: 'myUrl', type: "POST", data:
{ // data stuff here }, success: function ()
{ // does some stuff here... } }); } });


You can use the above code for all types of deleting options. If you would like to create a post based system including the delete button, learn how to intercept a jquery.ajax call with confirm()


Like & Share

Leave a Comment

Login to post a public Comment

Comments 2.

Facts And Fun
3 months ago

Very useful thanks for sharing this..

gadgets tech
5 months ago

Great stuff thank you