Reputation: 15
I've got a button for which I dynamically create target URI with jquery. Controller action will do some update on database and I want it to display view that call it in the first place. This view can differ. How do you deal with such a scenario?
The idea is that you click on label, provide translation for it, click save and you can see you translation on your current page. I made it work with single page just fine but scaling it up is a problem.
I know I can pass around current page URI and then parse it 'by hand' and put it in RedirectToAction but is there cleaner way?
Upvotes: 0
Views: 103
Reputation: 7814
I'd use a PUT and just update the label on the current page on Success.
Don't wrap the ajax call in a while loop. the success function is only called if the server returns a success (without checking the documentation I assume it is fired on some http 200 status or other)
If you just want to reload on success I guess the below would do it.
$.ajax({
type: 'PUT',
url: /my/url/for/adding/a/translation,
data: theTranslation,
success: function() {window.location.reload(true);}
});
Upvotes: 1
Reputation: 14672
Just use jquery.put to call your action.
This will not result in a redirect, instead jou can have a client side function that handles the return from the controller and updates the page DOM client side directly.
Upvotes: 0