This is a migrated thread and some comments may be shown as answers.

Return response from save handler

7 Answers 420 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 14 Dec 2011, 12:02 PM
I'm trying to return a response from my save handler:

     Sub ProcessRequest(ByVal context As HttpContextImplements IHttpHandler.ProcessRequest      
        ' Some save logic
         
        context.Response.Clear()
        context.Response.ContentType = "text/plain"
        context.Response.Write("{'result':'result value'}")
    End Sub

but in my success event handler I got null for "e.response". Any help would be appreciated.

7 Answers, 1 is accepted

Sort by
0
Ivan
Top achievements
Rank 1
answered on 14 Dec 2011, 03:32 PM
It turned out I was passing the response JSON string incorrectly. This partially fixed the problem (works in FF but not in IE):

      context.Response.Write("{""result"":""result value""}")
0
Peter Staev
Top achievements
Rank 1
answered on 14 Dec 2011, 05:25 PM
I also noticed the problem. When using FF i was able to pull the data from e.response but in IE it was not working. After searching in their source JS found the problem. There is a problem with getting the response from the hidden iframe they use to upload the files. In order to fix it find:
try{var d=c.contents().text()}
and replace it with :
try{var d=c.contents().find('html').text()}

If you are using the non-minified version find:
var responseText = iframe.contents().text();
and replace with:
var responseText = iframe.contents().find('html').text();

This will now work with both IE9 and FF (have not tested for backward compatibility with older versions of IE though).
0
T. Tsonev
Telerik team
answered on 19 Dec 2011, 09:18 AM
Hi Peter,

The Upload expects a plain-text response, not HTML. Return a simple text string (no markup) and a content-type set to "text/plain".

Ivan, please try debugging the server response with Fiddler/Firebug to see if it contains only valid JSON and nothing else.

Kind regards,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Peter Staev
Top achievements
Rank 1
answered on 19 Dec 2011, 09:24 AM
My response from the server was correct. I was returning for example {"x":"3"} and explicitly setting the content type to "text/plain" but still it was not working in IE9, because IE9 automatically wraps the response in an HTML tag when it is put in iframe. That's why you need first to get the HTML tag inside the iframe, and then get the text of that tag. So the fix still needs to be added in order to work. If needed i can attach a very simple HTML page that demonstrates the problem.
0
T. Tsonev
Telerik team
answered on 19 Dec 2011, 10:09 AM
Hello Peter,

We've never experienced this "automatic wrapping" behavior. We'll be glad to see the demo page, so we can investigate.

Regards,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Peter Staev
Top achievements
Rank 1
answered on 19 Dec 2011, 10:18 AM
Attached is the page that tests the .contents() and .contents().find("html") functionality. Note that the page mimics the functionality of the hidden iframes of the kendo upload and does not use the actual control.
I've just saw that FF also wraps the response in HTML but seems it successfully returns the text when only using .contents(), while IE cannot.
0
Accepted
T. Tsonev
Telerik team
answered on 20 Dec 2011, 02:50 PM
Hi Peter,

Thank you for sending the sample page. Turns out contents() is broken in jQuery 1.7

Please upgrade to 1.7.1 to resolve it.

All the best,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Upload
Asked by
Ivan
Top achievements
Rank 1
Answers by
Ivan
Top achievements
Rank 1
Peter Staev
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or