/    Sign up×
Community /Pin to ProfileBookmark

Flash doesn’t work via AJAX

Hello,

Does anybody know why flash doesn’t work on content dynamically loaded via AJAX? This is for a one-click CopyToClipboard function. I use [URL=”http://code.google.com/p/zeroclipboard/”]ZeroClipboard [/URL]for this.

HTML CODE (this works perfect with the clipboard() function)

[CODE]<label>Image link: </label><input id=”photo_direct_link” value=”test” /> [/CODE]

CLIPBOARD FUNCTION

[CODE]function clipboard() {
// Copy to clipboard
var photo_direct_link = new ZeroClipboard.Client();

photo_direct_link.setText( ” ); // will be set later on mouseDown
photo_direct_link.setCSSEffects( true );

photo_direct_link.addEventListener( ‘complete’, function(client, text) {
copiedToClipboard(‘Image link’);
} );

photo_direct_link.addEventListener( ‘mouseDown’, function(client) {
// set text to copy here
photo_direct_link.setText( document.getElementById(‘photo_direct_link’).value );
} );

photo_direct_link.glue( ‘photo_direct_link’ );

}

clipboard();[/CODE]

But then when I load the input via AJAX and call the clipboard() function, the input is loaded but it doesn’t convert to a Flash movie ?

AJAX

[CODE]$.post(“/get_flash_input/”, {‘file_id’ : fileId},
function(data) {

$(‘#flashInput’).append(‘<label>Image link: </label><input id=”photo_direct_link” value=”‘ + /*data.image_link*/ ‘test’ + ‘” /><br />’);

// Call the clipboard function
clipboard();

}, “json”);[/CODE]

I hope somebody can help me because I am searching quite some time to resolve this issue.

Greetings,
Christophe

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorOct 21.2010 — Maybe I am out of the problem... But doesn't Flash use his own SDK to interact with a DB? Isn't it Flex?

http://en.wikipedia.org/wiki/Adobe_Flex

Just Google for "Flex to database" and you might find some solutions according to your needs.
Copy linkTweet thisAlerts:
@yamaharussOct 21.2010 — I seem to recall having this problem.. I believe the issue is the actual loading of the Flash code via AJAX.. The workaround is to have the Flash script loaded into your page in a hidden div, then change the div display with your trigger.
Copy linkTweet thisAlerts:
@KorOct 21.2010 — I seem to recall having this problem.. I believe the issue is the actual loading of the Flash code via AJAX.. The workaround is to have the Flash script loaded into your page in a hidden div, then change the div display with your trigger.[/QUOTE]
That means you might have 2, 3...n Flash applications which will run, even hidden, on the same time, at a certain moment. That could provoke a memory leak, I suppose... Don't mention if there is a sound on them ?
Copy linkTweet thisAlerts:
@yamaharussOct 21.2010 — Can you use an iFrame and load the iframe src with a Flash coded page?
Copy linkTweet thisAlerts:
@KorOct 21.2010 — Flash and JavaScript (along with AJAX technique) were never been good friends. As a personal advice: don't force an unwanted marriage. As I said: Flash has his own technologies (compatible with most of the server-side languages) to deal this sort of things.
Copy linkTweet thisAlerts:
@Christophe27authorOct 21.2010 — I seem to recall having this problem.. I believe the issue is the actual loading of the Flash code via AJAX.. The workaround is to have the Flash script loaded into your page in a hidden div, then change the div display with your trigger.[/QUOTE]

Hi Yamaharuss,

Can you clarify a little more please?

Do you mean, on first page load, you have to hide the flash code by loading it in a hidden div, and then let the div be visible the moment you request the new content via AJAX? That's a little odd ...?

Also it's not just one call to AJAX ... The 'request-ajax-content-button' is actually a navigation for images which are dynamically loaded. The inputs are 'shareLinks' which are converted to Flash-elements for 'one-click-copy-to-clipboard' purpose and they must be generated on each request :-)

So can you clarify yourself a little more, perhaps with some code please?

Thanks!!!

Christophe
×

Success!

Help @Christophe27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...