2012-03-27 72 views
0

我有幾個變量,我用來調用Flash電影,但我不想包括在document.ready因爲首先我需要從jquery ajax響應一個變量。swfobject變量從ajax響應

var flashvars = { 
       "debug.enabled":"true", 
       "background": "#000", 
       "uploadUrl": "UploadImage.ashx?id=" + var_from_ajax} 

我已經在document.ready之外定義了var_from_ajax。

我的Ajax成功功能

success: function(data) { var_from_ajax = data.id; swfobject.embedSWF("movie.swf", "divID", "600", "400", "10.0.0", "expressInstall.swf", flashvars, params, attributes);} 

不過貌似我從大炮Ajax請求嵌入我的電影與可變..任何解決辦法嗎?

回答

1

當您創建flashvars.uploadURL時,它僅僅是「UploadImage.ashx?id =」加上當時的任何var_from_ajax。在設置了flashvars.uploadURL之後,從未引用var_from_ajax。試試這個:

success: function(data) { 
    flashvars.uploadUrl = "UploadImage.ashx?id=" + data.id; 
    swfobject.embedSWF("movie.swf", "divID", "600", "400", "10.0.0", "expressInstall.swf", flashvars, params, attributes); 
} 
+0

非常感謝,看起來像它現在的工作:)) – 2012-03-27 16:15:08