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 联系我们: