javascript - Dynamic array in jQuery -


i've got problem this:

if($.cookie('products') == undefined) {     $.cookie("products", [$(this).data('name')]); } else $.cookie("products", [$.cookie('products')+$(this).data('name')]); 

my goal add names of products cookie, cause need use them in php after sending them through form.

i'm using array, because in code need delete last object:

$.cookie("products", $.cookie('products').pop()); 

or maybe have solution transport variables jquery in 1 file php's variables in another?

okey, managed main problem using this:

var products = [$.cookie('products')]; products.push($(this).data('name')); $.cookie("products", products); 

but there's still problem pop() method:

products.pop(); $.cookie("products", products); 

instead of deleting last element removes whole array.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -