简体   繁体   中英

Unexpected Identifier Syntax Error in Javascript

I get an Unxepected Identifier editor with the following code. I've been troubleshooting it all day, and nothing. Hoping a fresh pair of eyes can spot my error. I'm trying to use jQuery UI to set up a date-picker and then get and manipulate the date. Changing the date on the picker should change an image on the page associated with that date via ajax.

$(document).ready(function(){
// Datepicker
$('#datepicker').datepicker({
    dateFormat: 'yy-mm-dd',
    inline: true,
    minDate: new Date(2012, 06 - 1, 1),
    maxDate:new Date(2012, 09 - 1, 31),
    onSelect: function(){
       var day1 = ($("#datepicker").datepicker('getDate').getDate()).toString().replace(/(^.$)/,"0$1");              
       var month1 = ($("#datepicker").datepicker('getDate').getMonth() + 1).toString().replace(/(^.$)/,"0$1");             
        var year1 = $("#datepicker").datepicker('getDate').getFullYear();
        var fullDate = year1 + "/" + month1 + "/" + day1;
        var dashDate = year1 + "-" + month1 + "-" + day1;
        var str_output = "<a id=\"single_image\" href=\"http://www.lasalle.edu/150/dayinhistory/" + fullDate + ".jpg\" title=\"\"><img src=\"http://www.lasalle.edu/scripts/timthumb/timthumb.php?src=http://www.lasalle.edu/150/dayinhistory/" + fullDate + ".jpg&w=560&h=350&zc=1&a=t\">";
        $('#this-day-photo-archive').html(str_output);
        var data = 'day=' + dashDate;
            $.ajax({
                url: 'http://www.lasalle.edu/150/content/day_grab.php',
                type: "GET", 
                data: data,     
                cache: false,
                success: function(html) {
                    $('#this-day-info').html(html);
                    console.log (html);
                    $(".left").click(function() {
                        $('#datepicker').datepicker( "setDate" , -1d );
                    });
                    $(".right").click(function() {
                        $('#datepicker').datepicker( "setDate" , +1d );
                    });
                }
            });
    } 

});

});

You should replace

 $('#datepicker').datepicker( "setDate" , -1d );

with

 $('#datepicker').datepicker( "setDate" , "-1d" );

(and the same for +1d )

A link to some examples for confirmation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM