如何循环 JSON GET 结果?

How to loop through JSON GET result?

我是 laravel 开发人员,我没有使用 jquery 的经验,我想在 dropbox 文件上传器上显示可编辑的图像,请帮助我如何动态化?谢谢你

Jquery 脚本

<script>
$(document).ready(function(){

    var data = @json($roomdetails);

    var   file ="{{Config('wfh.file')}}";

    $.each(data, function(i, item) {

        {id: 1, src: 'https://picsum.photos/500/500?random=1'},
    }),

     let preloaded = [
                {id: 1, src: 'https://picsum.photos/500/500?random=1'},
                {id: 2, src: 'https://picsum.photos/500/500?random=2'},
                {id: 3, src: 'https://picsum.photos/500/500?random=3'},
                {id: 4, src: 'https://picsum.photos/500/500?random=4'},
                {id: 5, src: 'https://picsum.photos/500/500?random=5'},
                {id: 6, src: 'https://picsum.photos/500/500?random=6'},
       ];


    $('.input-images').imageUploader({
        preloaded: preloaded,
        imagesInputName: 'images',
        preloadedInputName: 'old'
    });
});
</script>

这是静态图片,我想点赞。

 let preloaded = [
                    {id: 1, src: 'https://picsum.photos/500/500?random=1'},
                    {id: 2, src: 'https://picsum.photos/500/500?random=2'},
                    {id: 3, src: 'https://picsum.photos/500/500?random=3'},
                    {id: 4, src: 'https://picsum.photos/500/500?random=4'},
                    {id: 5, src: 'https://picsum.photos/500/500?random=5'},
                    {id: 6, src: 'https://picsum.photos/500/500?random=6'},
           ];

你的问题很不清楚。没办法知道你在问什么。当我查看您的代码时,我可能会提出以下建议。

<script>
$(function(){
  var data = @json($roomdetails);
  var file ="{{Config('wfh.file')}}";
  var preload = [];

  $.each(data, function(i, item) {
    preload.push({id: item.id, src: item.src});
  });

  $('.input-images').imageUploader({
    preloaded: preloaded,
    imagesInputName: 'images',
    preloadedInputName: 'old'
  });
});
</script>

因为你没有提供data的例子,我不知道这是否合适。