Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery cookie集引发意外字符串错误_Jquery_Cookies - Fatal编程技术网

jquery cookie集引发意外字符串错误

jquery cookie集引发意外字符串错误,jquery,cookies,Jquery,Cookies,我正在使用jquery cookie插件,在尝试设置时遇到了一个意外的字符串错误 jQuery('#select').change(function() { if(jQuery(this).val() == "defaultselect"){ jQuery.cookie('mycookie':'123456789'); // This line throws the error } return false; }); 您有一个语法错误:应该是, j

我正在使用jquery cookie插件,在尝试设置时遇到了一个
意外的字符串错误

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

您有一个语法错误
应该是

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