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

[英]jeditable - how to set the modified cell to an other value than the passed value?


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

也许我只是不够聪明。我开始使用jeditable并且工作正常,但我现在已经坚持了几个小时。

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

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

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 :).

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

$(".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.

我希望我只是愚蠢,你告诉我它是怎么回事。

1 个解决方案

#1


1  

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...

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

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.

因为它被称为ajax,异步,因为你的数据是异步回来的,但你的脚本是同步运行的,而不是等待服务器的回答,但是成功处理程序会这样做。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/02/06/c29c1b2ee10e580a81069ffa75cd789a.html



 
  © 2014-2022 ITdaan.com 联系我们: