How to transfer values ​​from one page to another in jQuery

I have two jQuery pages, Page1 and Page2, and I can get input to Page1.

somval=1000$.

The user of page 1 enters some value. I saved the value:

var val = somval;

Now on the second page I need to get the somvalue result on page 1. Of course, two pages using My1.js My2.js respectively.

How to share values ​​from one jQuery file with another javascript or how to get value from page1 value to page2?

How do I solve this problem?

+3
source share
3 answers

You can redirect the user to the next page with the data in the query line, and then on the second page you can parse the URL.

, :

window.location = 'page2.html?somval=' + somval;

URL:

var qsParm = new Array();
function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            qsParm[key] = val;
        }
    }
}

, .

jQuery, , , , .

+16

jQuery (.. , , , ), -.
URL-, , , - cookie, !
, , , Ajax ..

0

All Articles