1

In my page I have the following code

$('.admission-state', nodes[a]).editable(function(value, settings){
    window.output = '';
    $.post("{% url admissions_ajax_admission_state %}", 
    {id:$(this).attr('id'), value:value}, 
    function(data){window.output = data;}); 
        return window.output;
    }, 
    {
        loadurl: "{% url admissions_ajax_admission_state %}",
        type : "select",
        style : "inherit",
        submit : "OK",
        onblur : "ignore",
    }
     );

My issue is that in the callback function for the $.post I set window.output = data. This does not work. There must be a scope issue. At first I set var output = ''; then set it in the callback function. I eventually moved onto using window.output. This still doesn't work.

I would like to know how to set a variable in the callback that I can use to return in my .editable call, I would also like to know why the window.output or output set as var above isn't in global scope?

emperorcezar
  • 334
  • 1
  • 9
  • See [this question](http://stackoverflow.com/questions/562412/return-value-from-function-with-an-ajax-call). A very common issue. – Matt Ball Dec 09 '10 at 01:56

0 Answers0