gpt4 book ai didi

Javascript (JQuery) 变量覆盖问题

转载 作者:行者123 更新时间:2023-12-03 11:53:42 25 4
gpt4 key购买 nike

我有以下代码:

<script>
$(document).ready(function()
{
var settings_image ={
url:"<?php echo site_url('/cms/editor/upload/images');?>",
method: "POST",
fileName: "file",
returnType:"json",
onSelect:function(files)
{
var folder = prompt("Please enter sub-folder name for these images. If you do not enter anything, images will be uploaded to the root images folder", "");
if (folder != null) {
url:"<?php echo site_url('/cms/editor/upload/images');?>/"+folder;
}
}
};
});
</script>

我想做的是,当选择文件时显示 Windows 提示(在 onSelect 函数内)时,如果用户输入某些内容,则应使用文件夹中的新值重写上面第一步定义的 URL 属性路径。 URL属性基本上是调用php脚本来上传文件。

如何重写 if block 中的 URL 属性?

最佳答案

使用this作为当前引用。

var settings_image ={
url:"<?php echo site_url('/cms/editor/upload/images');?>",
method: "POST",
fileName: "file",
returnType:"json",
onSelect:function(files)
{
var folder = prompt("Please enter sub-folder name for these images. If you do not enter anything, images will be uploaded to the root images folder", "");
if (folder != null) {
this.url="<?php echo site_url('/cms/editor/upload/images');?>/"+folder;//resetting url
}
}
};

关于Javascript (JQuery) 变量覆盖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25697715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com