views:

1289

answers:

3

I'm using the jQuery plugin ajaxForm to submit a file upload form via AJAX. The script submits the form, which, upon success, runs uploadResponse() that adds a new row into a <table> on the page. It works fine in Opera, Firefox, Safari, IE7, and IE8.

However, IE6 does not run the uploadResponse() after the form has been submitted. The POST request from the script runs and you can see the file when you refresh the page. However, uploadResponse() simply does not run and the DOM is not updated.

Here is the portion of the script:

/**
 * Ajaxified upload form
 */
$('form#upload').ajaxForm(
{
 url: 'ajax/upload.php',
 success: uploadResponse,
 dataType: 'xml'
});

/**
 * Upload form response
 *
 * @param responseXML Returned from the AJAX POST
 */
function uploadResponse(responseXML)
{
 var displayName = $('display_name', responseXML).text();
 var fileName = $('name', responseXML).text();
 var directoryID = $('directory_id', responseXML).text();
 var abbrTitle = $('abbr_title', responseXML).text();
 var tableRow = 'file_' + tableRowCount;

 $('table#listing tbody').prepend(row(displayName, null, '', 'delete.php?directory_id=' + directoryID + '&file=' + fileName, 'Delete', null, tableRow, 'fileName jsHide', 'rename jsHide', 'delete jsHide', abbrTitle));
 $('td.jsHide').fadeIn();

 // AJAX renaming
 $('tr#file_' + tableRowCount).find('td.fileName').click(generateRenameForm);

 // Remove "no files" notficiation
 $('p#noFiles').remove();

 alternatingRows();
 tableRowCount++;
}

The particular code in the uploadResponse() function is not under question. It simply does not run (I tested it using alert()).

Also, IE6 displays the "this page contains secure and non-secure content" dialogue box. All of the scripts, stylesheets, etc. are all local on the secure server, so nothing as far as I'm aware is non-secure. I've checked over this pretty thorougly.

Thanks for any help.

A: 

Have you tested it in another pc? Maybe is a security setting in your IE6.

eKek0
No, but it is a default XP installation, so even if the default security settings don't work, the problem still persists.
Ethan
A: 

The datatype:xml is the issue. I'm not sure where I learnt this trick (all credit to that original source). This is how this problem can most likely be solved:

replace "datatype:xml" with

datatype: ($.browser.msie) ? "text" : "xml"

and before you start using the xml response you would need to do this:

function parseXMLResult(result) {
    var xmlDoc;
    if (typeof result == 'string') {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(result);
    } else {
        xmlDoc = result;
    }
    return xmlDoc;

}

Hopefully this should solve your problem.

Reg the secure/in-secure warning, you definitely have at least one element might be an image/css/js file which is loading over http. This problem is not specific to IE6 you should see the certificate symbol in the address bar of FireFox to have a red "i" indicating there are issues in the page. Use a tool like FireBug to figure out the offending element.

sankara
A: 

I have the same problem. But i don't know hom to solve. Do you fix it?

Yes, the solution highlighted in green above worked well.
Ethan