I’m using JQuery and MVC2 to make an AJAX request when the user clicks on a link. The links are using .live in jQuery like so:
$('.listdelete').live('click', function (event) {
event.preventDefault();
url = '/Controller/Action';
data = getArguments();
$.getJSON(url, data, function (data) {
alert('success!');
});
When I drop a break point in my controller I can see that on the first user click the controller action is found and executed. On subsequent clicks the getJSON call executes the success alert, but the controller code is not executed. Is there a problem using .live with getJSON?
The problem probably lies (if you are using IE) in the fact that the browser caches your request. So you have a success but no real call is made. To avoid this you should do something like this: