Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have issue with response of submit in ExtJS (response in JSON but somewhere HTML entered)

I get this response:

{"success":true,"errorCode":-1,"error":""}

No HTML inside the JSON, but the js say its entered:

uncaught exception: You're trying to decode an invalid JSON String: <pre>{"success":true,"errorCode":-1,"error":""}</pre>

The code: http://www.pasteall.org/30057/javascript

The issue has been fixed that so odd seem like when you upload a file the ExtJS submit can't handle the json response. If you make at html and convert violà you got at.

$this -> output -> set_content_type('text/html'); 

that all the problem

like image 705
Sivan Wolberg Avatar asked Oct 16 '25 17:10

Sivan Wolberg


2 Answers

The behaviour you experienced is actually documented (quite well buried, though) in ExtJS API docs - see description of Ext.form.Basic.hasUpload() method.

In short, file uploads are not performed by typical Ajax XMLHttpRequests. It uses a hidden iframe element instead. As a result, to quote ExtJS documentation:

If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html"...

Which is exactly how you seemed to eventually solve your problem - so, this explains why it indeed works. So it's "not a bug, but a feature". :-D

like image 67
Tommi Avatar answered Oct 18 '25 09:10

Tommi


It's hard to analyze the problem without seeing the code, so if you can add your code piece of client side, it may help.

Anyway, it seems that the result is returned in html format, i.e. contains non json data. Check why tags are included inside the result.

Check also the configuration of your server's page - it should be configured properly so to return JSON format.

It also explains why your result status is success. it is because the call to server operation was succeeded, i.e. the result was return to client without any error.

Now, after the server returned results to client, the store tries to operate the resulted data, but without success since the content is not in JSON format.

like image 31
sna19 Avatar answered Oct 18 '25 07:10

sna19