我有一個系統,用於將url文件存儲在mysql數據庫的每一行中。我想使用這些數據將其放入一個數組中,並在javascript函數中使用它。例如:如何將url文件放入javascript中的數組列表中
var files_list = "https://example.com/file1.docx,https://example.com/file2.docx,https://example.com/file3.docx,"; //value obtained via ajax
var links = [files_list];
這說明錯誤,所以我怎麼能分隔每個網址,並從中得到:
var links = ["https://example.com/file1.docx,https://example.com/file2.docx,https://example.com/file3.docx,"];
要這樣:
var links = ["https://example.com/file1.docx","https://example.com/file2.docx","https://example.com/file3.docx",];
我想一些幫助。