I’m using jquery_ujs to send a simple post request. I bound a callback function to the “ajax:success” event. However, this callback is being called twice for each successful post.
I know this is similar to this other question, but I checked my source and it doesn’t appear to be loading the jquery_ujs.js file twice (as suggested by many of the responses).
$(".new_item").bind("ajax:success",
function(xhr, data, status)
{
/* this is called twice for each call!*/
}
Anyone have any pointers? Thanks!
One of a few things are happening.
Either you have multiple elements with .new_item class
you are sending the ajax request twice
or you are binding the event twice
Note: If you are using a modern browser, replace alerts with console.log()