Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Submitting a form seems to be mis-interpreting the response type

  1. #11
    Sencha User
    Join Date
    Mar 2011
    Posts
    208

    Default

    Hi Guys,

    I am facing the same problem even if I set content type as text/html. below is my json script
    PHP Code:
    begin
    update image_gallary set picture 
    = :body where image_id = :v_image_id;
    :
    success := 'true';
    end
    It throws me below error as:
    • Uncaught Ext.Error: You're trying to decode an invalid JSON String: <pre style="word-wrap: break-word; white-space: pre-wrap;">{"success":"true"}</pre>
    ?Please let me know how to resolve this. One more thing is that it store image at server place but may be return response is wrongly interpreted. But not getting clue how to solve this . I am not getting message alert of success.

  2. #12
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    Judging by that error message it seems that the JSON is coming back wrapped in HTML pre tags. Check the response in Firebug to confirm. If this is the case then your problem is with your server, not ExtJS.

  3. #13
    Sencha User
    Join Date
    Mar 2011
    Posts
    208

    Default

    Ok. Do we have any other work arround for this ? My data is stored in the database for that image id, but my problem is I am not getting alert box for "successfully processed". Can we do any other way to display that message as least.

  4. #14
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    How are you checking that the content-type of the response is text/html?

    Are you seeing this problem in different browsers?

    Could you post the request and response headers for the request, as seen in Firebug or Chrome?

  5. #15
    Sencha User
    Join Date
    Mar 2011
    Posts
    208

    Default

    Please find screen shot of my network So my json always go as application/json .
    ScreenShot235.jpg
    I am not configuring my url as application/json rather in json file I am defined content type as text/html. which I can see in second line.

    Please let me know what could be solution or do i need to define sepearte store for this ?
    The above comes in chrome where as in firefox it askes me to save or open file. dialog box
    Attached Images Attached Images

  6. #16
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    I don't understand what it is you think you've done but you need to change the content-type of that response from application/json to text/html. In the screenshot it is clearly wrong. The behaviour you describe in both Chrome and Firefox is exactly what I'd expect given the content-type is wrong.

    I don't know how to change the content-type on your server. Please consult with the documentation because whatever you're doing at the moment is incorrect.

  7. #17
    Sencha User
    Join Date
    Mar 2010
    Posts
    25

    Default

    I had a problem with the file upload too. I noticed that if you put the keys not in quotes it in your response it fixes the issues:

    {"success":true} <- does not work
    {success:true} <- works, no invalid json error

  8. #18
    Sencha User
    Join Date
    Feb 2011
    Posts
    23

    Default FileUpload Uncaught Ext.Error: You're trying to decode an invalid JSON String:

    Hi ,

    I am getting "Uncaught Ext.Error: You're trying to decode an invalid JSON String: " when i try to submit the form with a file upload feature.I tried setting the response to text/html.This doesn't help.
    and one more problem is that a fakepath gets add when i upload a file.How to remove this fakepath and display the full path.

    I am using struts with extjs.

    Please help.
    Thanks,
    M.Vishwadharini

  9. #19

    Default

    So even though I want to parse JSON the response should be set to "text/html" instead of "application/json"? That makes little sense and though it worked for others, it doesn't for me because my JSON can contain an open angle bracket, which is valid in JSON, but which cannot be parsed when the content is text/html. Specifically the following valid JSON property:


    "handlingInst":"<DO NOT SEND INVOICES.DO NOT CHARGE FREIGHT>"

    Got transformed into the following invalid JSON:


    "handlingInst":"<do not=" " send=" " invoices.do=" " charge=" " freight=" ">"

    Substituting &lt; seems fraught with problems especially if it can be used in places where it will be displayed that way literally instead of as an angle bracket. We are already overriding JSON.parse so I will probably strip out any surrounding pre tags there, but the main point is that setting the Content-type to text/html can cause problems if the JSON contains angle brackets.

  10. #20

    Default

    Judging by that error message it seems that the JSON is coming back wrapped in HTML pre tags. Check the response in Firebug to confirm. If this is the case then your problem is with your server, not ExtJS.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 6
    Last Post: 8 Feb 2011, 3:45 PM
  2. Textfield interpreting text as HTML
    By richardm in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 9 Apr 2010, 10:26 AM
  3. Problem with response after submitting the Form
    By magnum99 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 28 May 2009, 5:12 PM
  4. How to get response JSON after form submitting?
    By karantir in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 25 Jul 2007, 5:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •