www.webdeveloper.com
Results 1 to 7 of 7

Thread: Flash doesn't work via AJAX

  1. #1
    Join Date
    Jan 2010
    Location
    Belgium
    Posts
    319

    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 ZeroClipboard for this.

    HTML CODE (this works perfect with the clipboard() function)
    Code:
    <label>Image link: </label><input id="photo_direct_link" value="test" />
    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();
    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");
    I hope somebody can help me because I am searching quite some time to resolve this issue.

    Greetings,
    Christophe

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    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.

  3. #3
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    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.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by yamaharuss View Post
    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.
    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

  5. #5
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    Can you use an iFrame and load the iframe src with a Flash coded page?

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    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.

  7. #7
    Join Date
    Jan 2010
    Location
    Belgium
    Posts
    319
    Quote Originally Posted by yamaharuss View Post
    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.
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles