0

I have an app where user goes through a number of steps in different tabs such as filling forms, making selections etc. Tables are updated by ajax.

I want to be able to figure out user changes between tabs so that if a user moves from one tab to next without making changes a modal will ask him if he is sure he wants to go to the next step without completing previous. I am thinking to do this by checking certain session variables and since I don't want to refresh page I want to use ajax. Does anyone know how this is possible??

How can I send session variables in my ajax responses??

Suemayah Eldursi
  • 969
  • 4
  • 14
  • 36
  • Do you need to use AJAX here? A full javascript solution would be much easier. http://stackoverflow.com/questions/959670/generic-way-to-detect-if-html-form-is-edited You'd obviously need to tweak this a little bit and use bootstrap events but shouldn't be a huge issue. – user1669496 Sep 26 '16 at 16:31

2 Answers2

0

Yes, You can send a request to check the session variables on the server.

Max B
  • 42
  • 8
0

You can do it fully using jQuery . If you have a step form just put on jQuery on next click like this :

$('#next').on('click', function () {
if (formIsValid()) {
        // move to next step 
    var data1 = $('#input1').val(); // get data from all form fields like this

    // if you want to save data you can use
    // Jquery sessionstorage or localstorage APIs

    $.ajax({
        // write your ajax code here 
    })
} else {
    // show alert and do other stuff
}});

If you want to store data temporarily use JQuery's localstorage or sessionstorage.

Nitesh Verma
  • 2,460
  • 4
  • 20
  • 36