Jquery Impromptu - how to set the html of a state after reading data from a html file

247 Views Asked by At

In the Impromptu popup I have two states viz. state1 and state2. The data for the "html" of state2 has to be read from a file(abc.html). I have tried reading the file in state1 and setting it to a variable and using that variable as the data for state2 html, but its not working.

var secondPage = '';

//And when defining states

state0: {
    html:'First html',
    buttons: { Cancel: false, Next: true },
    focus: 1,
    submit:function(e,v,m,f){
        if(v){
            e.preventDefault();
            // have tried this but not working
            $.get('abc.html', function(data) {
                secondPage = data;
                $.prompt.goToState('state1');
            });
            //$.prompt.goToState('state1');
            return false;
        }
        $.prompt.close();
    }
},
state1: {
    html:secondPage, // this secondPage should be read from a abc.html file
    buttons: { Back: -1, Exit: 0, DoSomething: 1 },
    focus: 1,
    submit:function(e,v,m,f){
        e.preventDefault();
        if(v==0)
            $.prompt.close();
        if(v==1)
            // do something
        else if(v==-1)
            $.prompt.goToState('state0');
    }
}
0

There are 0 best solutions below