Return response from save handler

8 posts, 1 answers
  1. Ivan
    Ivan avatar
    3 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2011 Link to this post

    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.
  2. Ivan
    Ivan avatar
    3 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2011 Link to this post

    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""}")
  3. Peter Staev
    Peter Staev avatar
    20 posts
    Member since:
    Dec 2009

    Posted 14 Dec 2011 Link to this post

    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).
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2831 posts

    Posted 19 Dec 2011 Link to this post

    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!
  5. Peter Staev
    Peter Staev avatar
    20 posts
    Member since:
    Dec 2009

    Posted 19 Dec 2011 Link to this post

    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.
  6. T. Tsonev
    Admin
    T. Tsonev avatar
    2831 posts

    Posted 19 Dec 2011 Link to this post

    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!
  7. Peter Staev
    Peter Staev avatar
    20 posts
    Member since:
    Dec 2009

    Posted 19 Dec 2011 Link to this post

    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.
  8. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2831 posts

    Posted 20 Dec 2011 Link to this post

    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!
Back to Top