Error when attempting to parse xhr response text in fineUploader

别来无恙 提交于 2019-12-04 22:16:53

问题


I bay this fine-uploader version 3.3.0 now, and integration all lib in my site i think uploads make working its ok, but no! i see error my javascript console:

[FineUploader] Sending upload request for 0

[FineUploader] xhr - server response received for 0

[FineUploader] responseText = 

and error firebug:

[FineUploader] Error when attempting to parse xhr response text (SyntaxError: JSON.parse: unexpected end of data)

at line error: jquery.fineuploader-3.3.0.min.js(line 148)

i use params:

$(document).ready(function () {
    $('#uploader').fineUploader({
    request: {
        endpoint: '/upload/'
      },
    classes: {
        success: 'alert alert-success',
        fail: 'alert alert-error'
         }, 
    text: {
        uploadButton: '<i class="icon-upload icon-white"></i> file target'
      },
       validation: {
      sizeLimit: 31457280 

      },             
    debug: true

    });
  });

if i am write sizeLimit: 10485760 - it all right ok working! file uploads to finish. If write sizelimit: 31457280 file not uploads to end, process break to 2 or 3%. Help me! where bug? Please help me somebody!


回答1:


The following log message:

Error when attempting to parse xhr response text (SyntaxError: JSON.parse: unexpected end of data)

Generally indicates your server is not returning a valid JSON response. This is usually caused by an unexpected error server-side. Note that you must ALWAYS return a valid JSON response from your server. If you are using IE9 or older, be sure to return a response code of 200 as well.




回答2:


I was also facing the same issue with my script which was working on local perfectly but not on server.

Some points we need to ensure:

  1. Set the endpoint correctly as stated here

  2. Make sure your directory where the script is about to upload the file initially (in my case it was example-advanced\uploads ) is write-able. It should have 777 permissions. I was having problem here.

  3. max_file_upload_limit should be set accordingly.

There might be more. But these are few that I have faced so far. Hope this would help somebody.




回答3:


For coldfusion folks this is the code that fixed my issue

<cfoutput>

<cffile
action       = "upload"
fileField    = "QQFILE"
destination  = "#application.OSSandbox#"
accept       = "image/jpeg"
nameConflict = "MakeUnique"
result="imgUploadResult"
/>
<cfset json = CreateObject("component", "#application.CFCRoot#.json2")> // custom code to create a json object
<cfset dataset = json.encode(imgUploadResult,"array")>
<cfset dataset = REReplace(dataset,'("recordcount")','"success": true, \1')>

<cfcontent type="text/plain; charset=ISO-8859-1"><cfoutput>#dataset#</cfoutput>
</cfoutput>


来源:https://stackoverflow.com/questions/15611183/error-when-attempting-to-parse-xhr-response-text-in-fineuploader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!