开发者

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.

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 开发者_如何学Goproblem, 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜