Hello,
I've tried everything I can think of and all the of the solutions on the board but I can still not get file uploads using Malsup's form plugin to work correctly in webkit browsers.
Works fine in firefox. Files actually do upload in Webkit, but the response is never evaluated.
Ive used the <textarea> recommendataion, I think I'm doing it correctly:
- response.setContentType("text/html");
- return "<textarea>{\"error\":\"Attempting to update non existing answer\"}</textarea>";
And this works fine in firefox. In chrome, it tells me "erorr reading property error of udefined".
Here is the javascript:
- $(document).ready(function() {
- $('#fq${fn:escapeXml(id)}').ajaxForm({
- beforeSubmit: function(a,f,o) {
- o.dataType = 'json';
- o.iframe = true;
- $('#uploadOutput${fn:escapeXml(id)}').html('Uploading...');
-
- },
- success: function(data,textStatus, xhr,form) {
- var redirectURL = xhr.getResponseHeader('CSR-Redirect-URL');
- if (redirectURL!=null && redirectURL.length > 0) {
- window.location = location;
- return response;
- }
- if(data.error!=null){
- alert("Received Server Error:"+data.error);
- }
- /* var $out = $('#uploadMessage${fn:escapeXml(id)}'); */
- $('#uploadMessage${fn:escapeXml(id)}').html('<strong><a href="'+data.url+'" target="_blank">' +data.fileName +
- '</a></strong> uploaded successfully      <a href="javascript:submitAjaxURL(\'${base_delete_url}/'+data.id+'\',\'${fn:escapeXml(id)}\',handleFileDelete);">delete(X)</a>');
- handleCommonAnswerAttributes(data,'${fn:escapeXml(id)}',form);
- $('#uploadOutput${fn:escapeXml(id)}').html(' ');
- }
- });
- });
Again, in chrome/safari the output stays at "Uploading..." while the file actually is uploaded, you have to refresh the page to see that.
Ive seen it work on the demo page, so Im assuming Im doing something wrong. I've spent at least 2 days on this. Any help would be appreciated. Using Spring MVC in case that helps.
Thanks
-A