mrpatg
mrpatg

Reputation: 10117

jquery cookie set throwing unexpected string error

Im using the jquery cookie plugin and getting an unexpected string error when attempting to set it.

jQuery('#select').change(function() {
    if(jQuery(this).val() == "defaultselect"){
        jQuery.cookie('mycookie':'123456789'); // This line throws the error
    }
    return false;   
});

Upvotes: 1

Views: 398

Answers (1)

Muhammad Usman
Muhammad Usman

Reputation: 12503

You have a syntax error : should be ,

jQuery('#select').change(function() {
    if(jQuery(this).val() == "defaultselect"){
        jQuery.cookie('mycookie','123456789'); //`:` should be `,`
    }
    return false;   
});

Upvotes: 2

Related Questions