2011-09-04 58 views
0

我設置了returnStatus值成功。但沒有顯示價值。如果我在return(returnStatus)之前設置了returnStatus的值,那就是工作。我如何設定成功價值並使用它?jquery得到的值

Thanks for Answers。

我的jquery代碼;

(function($) { 
    $.fn.MubsisAjax = function(options){ 
     var defaults = {    
      Tabs  : false 
     } 

     var returnStatus = ""; 

     var jqxhr = $.ajax({ 
      type  : "POST", 
      url   : "post.asp", 
      //cache  : true,  
      //ifModified : true, 
       success  : function(event){ 
        returnStatus = "value" 
       } 


      }); 
    //returnStatus = "value" 
    return(returnStatus) 

    } 

})(jQuery); 
+0

這真是一個javascript初學者問題,我沒有足夠的精力在這裏作出答案。 – Drasill

+0

@Drasill:但你可以寫評論... – Chandu

+2

[jQuery:在ajax調用成功後返回數據]的可能重複(http://stackoverflow.com/questions/5316697/jquery-return-data-after-ajax -call-success) –

回答

0

它不能工作,因爲函數正在返回imediatelly,而不是等待Ajax的響應。你可以調用你的函數成功:回調