1

In order to signout from my webapp, I need to call a json to signout (clear all cookies)

logout:->
    $.get('/signout.json')

However, I am unsure how I can refresh the page + redirect the web page to the address i want e.g. /#!/signin? after the signout is successful.

1
  • What web framework are you using? e.g. ASP.NET, php etc?
    – Russell
    Dec 6, 2011 at 8:22

1 Answer 1

1

if you want to solve it in javascript just use window.location = "yourlinkhere"

I use the same sort of thing to determine if I have to show a push notification. I also use asp.net and vb.net so not sure if it will help you but you will get a basic idea of what to do :)

//admin is the controller the second is the function.
 $.post("/admin/UpdateBrainBattle/

That function will return a json. in this case its about submitting a form. so you check if the form is valid or not. in the end it shows this:

 Return Json(New With {.status = "error"})

or when its good its with .status = "ok" Then I get the json back on my page. This is the whole function(including the post function)

$.post("/admin/UpdateBrainBattle/" + sessionId, { questionId: key, startTimeField: startTimeField, startDateField: startDateField },
                   function(data) {
                        if (data.status == 'ok'){
                         parentLi.find('li.onedit').hide();
                         parentLi.find('li.onview').show();
                         parentLi.find('div.dateTimeBlock div.view').html(data.value).show();
                         parentLi.find('div.dateTimeBlock div.edit').hide();
                         $('.errorBlockSummary').hide();
                         }
                         else
                         {
                            parentLi.find('span.errorBlock').show();
                            $('.errorBlockSummary').show();
                         }
                   });

This way you can tell your page, if everything was succesful go to this page, otherwise take this action. Hope this helped you a bit on your way :)

Edit: noted you used a $.get instead, it can work exactly the same way as long as the function you call to has a return value you should be fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.