2016-05-13 132 views
2

我想恢復變量「idl」在函數遠程我有使用window.var,但這是行不通的。 有我的代碼。從其他函數恢復變量

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(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);} 

請幫我謝謝你提前。

+0

的可能的複製[怎麼辦我返回異步調用的響應?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – madalinivascu

+0

'$('#refresh ').click({param:status},screenshotRefresh);'這段代碼假設要做什麼? – madalinivascu

+0

你好,謝謝你的回答刷新是一個按鈕,將調用函數screenshotRefresh.this函數將加載圖像形式的服務器,並將其顯示爲html –

回答

0

成功函數內遙控功能的AJAX的異步性有功能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); 
      } 
     ); 
    }