jeditable - 如何将修改后的单元格设置为传递值之外的其他值?

发布于 2024-10-15 19:54:51 字数 1190 浏览 4 评论 0原文

也许我只是不够聪明。我开始使用 jeditable,它工作得很好,但我现在被困了几个小时。

我正在使用选择字段,单击时显示(感谢 jeditable),并将编辑后的数据存储在数据库中,到目前为止一切顺利。

问题是,我从服务器端得到结果,我必须在编辑字段中设置该结果。默认情况下,它将设置为选择中所选字段的值。

我不明白为什么在 ajax 请求完成(或开始?)之前就开始返回。所以不可能返回结果。当然,我的第一个想法是我在complete: function() 中触发 return,但没有:)。

$(".columnSelectLine").editable( function(value, settings) {
        var result;
        $.ajax({
            url:'/ajax/jq_ajax_scripts.php',
            type:'post',
            data:'request=wizardSaveFromTableColumnMapping&dbName='+dbName+'&dbTableName='+dbTableName+'&column='+this.id+'&value='+value,
            success: function(data) {
                result = data;
            },
            error: function(req) {
                alert("bad");
            }
        });
        console.log(result);
        return(result); // result is empty || return(value) works but is the commited value from the select field


    }, {
    loadurl : '/ajax/jq_ajax_scripts.php?request=wizardGetColumnMappingValues&dbName='+dbName+'&dbTableName='+dbTableName+'&id='+this.id,
    type    : 'select',
    onblur  : 'submit'  
});

我希望我只是个傻子,你告诉我事情进展如何。

maybe I'm just not smart enough. I started working with jeditable and it works fine, but I'm stuck for hours now.

I'm using select fields, shown up on click (thanks jeditable), and I store the edited data in the DB, so far so good.

The problem, I get a result from the server side, which I have to set in the edited field. By default it will be set to the value from the selected field in the select.

I don't understand why the return started before the ajax Request is done (or started?). So its impossible to return the result. And sure, my first thought was I fire the return in the complete: function(), but no :).

$(".columnSelectLine").editable( function(value, settings) {
        var result;
        $.ajax({
            url:'/ajax/jq_ajax_scripts.php',
            type:'post',
            data:'request=wizardSaveFromTableColumnMapping&dbName='+dbName+'&dbTableName='+dbTableName+'&column='+this.id+'&value='+value,
            success: function(data) {
                result = data;
            },
            error: function(req) {
                alert("bad");
            }
        });
        console.log(result);
        return(result); // result is empty || return(value) works but is the commited value from the select field


    }, {
    loadurl : '/ajax/jq_ajax_scripts.php?request=wizardGetColumnMappingValues&dbName='+dbName+'&dbTableName='+dbTableName+'&id='+this.id,
    type    : 'select',
    onblur  : 'submit'  
});

I hope I'm just dumb and you tell me how it goes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2024-10-22 19:54:51

看,你设置结果,然后调用 ajax,然后运行控制台,然后返回结果,然后,一次,也许一秒钟后,结果从服务器返回。您需要将数据并设置在成功处理程序中,以前没有...

因此它被称为ajax,异步,因为您的数据异步返回,但您的脚本同步运行,而不等待答案来自服务器,但成功处理程序确实如此。

look, you set result, then you call the ajax, then you run the console, then you return result, and then, one time, after maybe a second, the result comes back from server. You need to put your data and setting your data in the success handler, nowhere before...

because of this it´s called ajax, asynchronous, because your data comes back asynchronously, but you script runs synchronously through, not waiting for an answer from server, but the success handler does.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文