I’m currently trying to do the same function the Ajax.BeginForm helper does but instead of doing it through a input submit tag doing it on a set interval of about 30 seconds.
@using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "shipmentTable", OnComplete = "OnSuccess"}))
Works perfectly but can’t seem to translate it into a working jquery.ajax call. The post controller has two arguments, a minDate and a maxDate. The Raw URL being something like Home/Shippments?minDate=arg1&maxDate=arg2. I have tried may variations of something along the lines of:
setInterval(function () {
$.ajax({
type: 'POST',
url: '/Home/Shipping',
dataType: 'html',
success: OnSuccess
});
}, 30000);
With no luck. Just wanted to see if anyone could help me out. Cheers.
UPDATE:
This seems to work good just had to change the parameters in the controller to just the accept FormCollection only.
setInterval(function () {
$.ajax({
type: 'POST',
data: $('form').serialize(),
url: '/Home/Shipping',
dataType: 'html',
success: OnSuccess
});
}, 30000);
I seems like all the the answers worked pretty well.
You are passing a string to the success function. Pass the function itself which will be something like this:
Or combine it:
If you got firebug, you can see the status of the Ajax call, what does it return? Any error code or success?