2

I want to recuperate variable "idl" in the function remote i have use window.var but that's not work. there is my code.

function stbStatus(stbInfo){
$.post(
        'indexFunctions.php',
        {
            stbInfo : stbInfo
        },
                    function(data){
                        $('#screenshot').html(data);
                        $('#refresh').click({param:status},screenshotRefresh);
                        $('form').click(function() {
                         window.idl = this.id;
                        ({param:status},remote);
                         });

                    }

                );
            }
        );
    },
    'json'
);}

Function Remote:

function remote(event){
    event.preventDefault();
    $('html').css('cursor','wait');
    var key = $("#"+window.idl).attr('class');
        $.get(
            'indexFunctions.php',
            {
                keyName: key
            },
            function(){
                if (key!="KEY_POWER" && key!="RESET")
                    screenshotRefresh(event);}

Please help me thank you in advance.

Ktari zied
  • 157
  • 1
  • 2
  • 13

2 Answers2

0

Because of the async nature of the ajax you need to call the remote function inside the success function of the ajax call

madalinivascu
  • 32,064
  • 4
  • 39
  • 55
0

there is the code of function screenshotrefresh

function screenshotRefresh(event){
    event.preventDefault();
    $('html').css('cursor','wait');
    $.post(
        'indexFunctions.php',
        {
            screenshot : event.data.param
            },
            function(img){
            $('html').css('cursor','default');
                $('#screenshot').html(img);
            }
        );
    }
Ktari zied
  • 157
  • 1
  • 2
  • 13