简体   繁体   中英

swfobject variable from ajax response

I have several variables which i use to call flash movie, but i dont want to include that on document.ready because first i need one variable from jquery ajax response.

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

I have defined var_from_ajax outside document.ready.

My Ajax success function is

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

But looks like i cannon embed my movie with variable from ajax request.. any solution?

When you create flashvars.uploadURL , it is simply "UploadImage.ashx?id=" plus whatever var_from_ajax is at that time. After flashvars.uploadURL is set, var_from_ajax is never referenced. Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM