setDates数组格式不起作用

时间:2016-10-06 11:16:52

标签: php ajax bootstrap-datepicker jquery-multidatespicker

我想在按钮点击时动态设置日期。以下是我从函数中获得的响应:

import random
from Tkinter import *


class Model(object):
    def __init__(self):
        self.currentMovie = 0

    def UpdateCurrentMovie(self):
        self.currentMovie = random.randint(0, 100)
        print(self.currentMovie)

    def UpdateWatched(self):
        print(self.currentMovie)

    def ExampleWithArgs(self, arg):
        print("ExampleWithArg({})".format(arg))


def main():
    model = Model()
    root = Tk()
    root.title("MovieSelector9000")
    root.geometry("900x600")
    app = Frame(root)
    app.grid()
    canvas = Canvas(app, width = 300, height = 75)
    canvas.pack(side = "left")
    button1 = Button(canvas, text = "SetRandomMovie", command=model.UpdateCurrentMovie)
    button2 = Button(canvas, text = "GetRandomMovie", command=model.UpdateWatched)
    button3 = Button(canvas, text = "ExampleWithArg", command=lambda: model.ExampleWithArgs("foo"))
    button1.pack(anchor = NW, side = "left")
    button2.pack(anchor = NW, side = "left")
    button3.pack(anchor = NW, side = "left")
    root.mainloop()

if __name__ == "__main__":
    main()

如果我手动放置上面的响应,那么它可以正常工作,但是点击一个按钮就无法正常工作。

如果我从Ajax传递日期,则会自动添加var result = ['2016-12-05','2016-12-12','2016-12-19','2016-12-26','2016-12-06','2016-12-13','2016-12-20','2016-12-27' ,'2016-12-07','2016-12-14','2016-12-21','2016-12-28','2016-12-01','2016-12-08','2016-12-15','2016-12-22' ,'2016-12-29','2016-12-02','2016-12-09','2016-12-16','2016-12-23','2016-12-30','2016-12-03','2016-12-10' ,'2016-12-17','2016-12-24','2016-12-31','2016-12-04','2016-12-11','2016-12-18','2016-12-25'] ,如下所示:

"

这是ajax请求:

"'2016-12-05','2016-12-12','2016-12-19','2016-12-26','2016-12-06','2016-12-13','2016-12-20','2016-12-27','2016-12-07','2016-12-14','2016-12-21','2016-12-28','2016-12-01','2016-12-08','2016-12-15','2016-12-22','2016-12-29','2016-12-02','2016-12-09','2016-12-16','2016-12-23','2016-12-30','2016-12-03','2016-12-10','2016-12-17','2016-12-24','2016-12-31','2016-12-04','2016-12-11','2016-12-18','2016-12-25'"

以上ajax结果如下:

$.ajax({
    type: "POST",
    data: {month:selected_month},
    url: 'http://test.com/v/get_data',
    success: function(result) {
        var day_of_week = [result];
        $('#spotone').datepicker('setDates', result);
    }
});

0 个答案:

没有答案