[ 6 posts ]

De Metter Kenny

  • Username: Kenny
  • Joined: Mon Dec 27, 2010 1:38 am
  • Posts: 7
  • Offline
  • Profile

ajax application with fileupload script errors in iframe

Post Posted: Fri Dec 31, 2010 2:15 am
+1-
Hello,

I have an asynchronous application , which is using file upload.

In order to achieve this , i use the setForm(form,true) , which enables fileupload , according to the documentation.

As i understand it , this works by creating a hidden iframe, and submitting the form with as target the iframe.

In the page i'm showing , this works fine. After performing the call , i can retrieve the content with the upload callback function.



However , the problem i have is that the iframe itself is throwing script errors.

To clarify , i'll explain the setup of my application :

- I have a start page (base.jsp ) , which loads synchronously at start
- This page includes certain script files in the head , needed in the application

- The page content a 'content' div , in which i load the content i asynchronously retrieve from the server.

- This content contains scripts , which use functions from the included script files in the head


The problem is the following :

=> When doing a fileupload , the retrieval of the page is done by using the hidden iframe
=> When the content is loaded into this iframe , it executes the scripts .
=> However , in the content , i'm not loading the script in the head again , as otherwise they would be loaded twice in the actual screen

=> As a result , i'm getting script errors in the iframe , as it cannot find my script includes there.


Is it possible to block script executing in the iframe , or tell the browser that it shouldn't interpret the html ?

Thanks,
Kind regards,

Kenny,

De Metter Kenny

  • Username: Kenny
  • Joined: Mon Dec 27, 2010 1:38 am
  • Posts: 7
  • Offline
  • Profile

Re: ajax application with fileupload script errors in iframe

Post Posted: Wed Jan 05, 2011 3:37 am
+0-
anyone ?

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: ajax application with fileupload script errors in iframe

Post Posted: Wed Jan 05, 2011 8:25 am
+0-
Hi Kenny, Is the script file you are trying to load the file that was uploaded, or does your server process the file upload to create the returned script file? I use YUI GET to load and execute javascript files asynchronously all the time with no issues. Don't know if you can somehow call GET to read the script file on the success return from the server fileupload event.

The docs for GET are at http://developer.yahoo.com/yui/get/#script for what its worth.

Todd

De Metter Kenny

  • Username: Kenny
  • Joined: Mon Dec 27, 2010 1:38 am
  • Posts: 7
  • Offline
  • Profile

Re: ajax application with fileupload script errors in iframe

Post Posted: Thu Jan 20, 2011 3:07 am
+0-
The script file is just loaded in the page itself .

The problem is the content i get back from the server , which calls function that are in the script file.

The content is put inside a container div , and then the scripts inside the updated container are updated , calling scripts that are defined in the head ( the head contains script files which are used ).

This all works in normal asynchronous requests.

However , when you do asynchronous request with fileupload ( setForm with second parameter to true ) , it puts the content in an iframe first ( creates a hidden iframe ).

The problem is that this iframe already tries to execute the scripts , but since the content is using functions from a script file , it cannot load them , and gives script errors.

So , if after uploading a file , you want to show updated content on the screen , and iframe will be created , which tries to execute scripts functions that are not loaded in the iframe itself.

What i would want is that the browser doesn't interpret those scripts in the iframe , and just uses the iframe as a conduit. But i'm not sure that is possible ?

Thanks,
Kind regards,
Kenny,

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: ajax application with fileupload script errors in iframe

Post Posted: Thu Jan 20, 2011 7:54 am
+0-
Kenny, I think I understand ... you are getting errors locally (on the YUI client) BEFORE you send the file "down the wire" to your server, correct?

Can you post a link or a link to a pastie location to look at some of your code?

Todd

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: ajax application with fileupload script errors in iframe

Post Posted: Thu Jan 20, 2011 9:57 am
+0-
As followup, I am able to upload mixed HTML / Script files to the server using setForm with Connect.asyncRequest. Checked it on FF 3.6, Chrome and Safari (not IE). Make sure your form tag includes the proper encoding ..
Code:
<form method="post" id="myForm" action="myaction" enctype="multipart/form-data">

Todd
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum