开发者

Implementing a simple file upload in extjs

开发者 https://www.devze.com 2023-01-08 01:06 出处:网络
When the file is uploaded with standardsubmit set to false (开发者_StackOverflowthe default) the file uploads, but then a javascript error crashes it because it cannot parse the reply - it\'s expectin

When the file is uploaded with standardsubmit set to false (开发者_StackOverflowthe default) the file uploads, but then a javascript error crashes it because it cannot parse the reply - it's expecting a JSON response.

When set to true, it works, but you cannot alter the target (or if you can, I can't find out how), which is something I need to do, I need it to upload to an invisible iframe to prevent the page posting back.

Is there some way to get it to ignore the response or accept a normal http response? I am not convinced submitting a form even gives you a response. I just want to run code once the file is uploaded.

Anyone have any ideas? The error is basically within the library itself, trying to parse a json response but the response is an empty string so it errors.


There is no error. The FormPanel expects to receive { success: true } if everything went well, or { success: false, errors: [...] } if something went wrong.

Based on this reply, the handler actually calls other event handlers responsible for highlighting the fields that failed server-side validation, etc.

You need to change your server side script to return what ExtJS expects it to return.


There is a serious lack of documentation (or at least, searchable documentation) for extjs! Eventually I found the solution, which allowed me to change the target. It was control.dom.target I believe. This was the ideal solution too because I didn't want to implement a 'hack' of server-side code for a specific client-side solution.

Incidentally, returning { success: true } also worked, I tried it afterwards.

0

精彩评论

暂无评论...
验证码 换一张
取 消