views:

668

answers:

9

I have a form to upload a file.The <html> is as follows:

<div id="divModalPopup" class="ui-dialog-content" style="height: 139px; width: 268px;">
  <form method="post" action="upload.php" target="uploadframe" enctype="multipart/form-data">
    Please choose a file to upload [only zip with shape files and no folders]: 
    <input type="file" name="uploadFile"/><br/><input type="submit" value="Upload"/>      
  </form>
  <iframe style="display: none;" onload="uploadStatus();" id="uploadframe" name="uploadframe"/>
</div>

And on clicking upload, i send a post request to a php file,whose response is shown on the iframe. The javascript function for the same :

function uploadStatus(){

   var resp = document.getElementById('uploadframe').contentDocument.body.innerHTML;

   if ("" != resp){

      jQuery("#divModalPopup").html(resp);

   }

}

The issue I am facing here is that, even after i get the response(firebug shows the correct response), <firefox> shows a waiting cursor and loading.. icon in the tab.

Any idea as to why this is happening??

There's nothing but an echo statement in the php file.

Also, this doesn't happen on other browsers like Chrome and safari. A tcp packet capture shows that the transaction is complete.

A: 

Does it happen in other browsers like chrome, opera, safari ?

letronje
A: 

Try after disabling firebug... just to eliminate one possibility.

Amit
+1  A: 

Could it be a firefox specific bug as none of the other browsers are exhibiting it ? A tcp packet capture and "net" tab in firebug should confirm that the response was completely sent back by the php script.

letronje
+1  A: 

Put something in your response. If you only have an echo statement in your php file, the response is empty and Firefox is known to have trouble with empty ajax response.

Try this in your php:

<?php
echo("something");
header("Content-type: text/html");
?>
Alsciende
A: 

does the issue occur if you remove the onload() function for the hidden iframe ?

letronje
The problem seems to be with the JQuery part on the onload() function. I use a jQuery statement to set the html of a popup as the response [jQuery("#divModalPopup").html(resp)];. And if i remove/comment that statement, the problem is solved.
+1  A: 

This usually happen when there is no content-length header (or the headers is present but with an incorrect size)

You should look at the headers. If the header isn't there, You'll have to play a little with .htaccess

Also, make sure you don't have any strange character after the php closing tag "?>"

The Disintegrator
Thanks for the downvote.Actually the scenario I'm describing happened to me.We're trying to help you and this is your way to say thank?
The Disintegrator
+1  A: 

I was having a similar problem and I found this article which proved to be helpful.

Basically the problem is caused when removing the iframe from the DOM inside the onload handler.

mtomis
A: 

If you have the firebug plugin installed in Firefox then you can see all the http requests live. So open firebug, open the "net" tab and reload the page. You will be able to see what POST/GET requests are being called and hopefully be able to solve the problem with that.

xtheonex
+1  A: 

Add ';return false;' after your javascript call.

<iframe style="display: none;" onload="uploadStatus();return false;" id="uploadframe" name="uploadframe"/>

pcp