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

Thread: [2.1][FIXED] Ext.Ajax.request jsonData option does not submit data

  1. #11
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    4

    Default

    The first red line change is correct, and I've updated that in SVN:
    Code:
    var method = o.method||this.method||((p || o.xmlData || o.jsonData) ? "POST" : "GET");
    Animal is correct regarding the disableCaching param -- it was actually a bug in previous versions that it sometimes got appended when not needed. In 2.1, it is only auto-appended for GET calls, although you can force it for any method by adding disableCaching:true explicitly. Again, for POSTs, this should never be needed.

    The second red line correction, as mentioned by halkon_polako, should not be needed since params are still valid with JSON or XML data in some cases.

  2. #12
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default

    Hi, I'm using v2.1 and having this problem even with the override from the posts above. I believe that the problem is in the ext-base adapter however I was unable to track it. When I use YUI adapter everything is fine.
    Here, I posted two very simple pages for you to see the problem, please use Firebug to analyse the requests:

    http://elishnevsky.qsh.ru/page1.htm - AJAX request with ext-base adapter

    http://elishnevsky.qsh.ru/page2.htm - same AJAX request with YUI adapter

    The code in both files makes a simple ajax request with both params and jsonData together. See the source. The request is done to an ASP.NET HttpHandler, which simply writes to the output the value of jsonData. Here's the code just in case:
    Code:
    <%@ WebHandler Language="C#" Class="Handler" %>
    using System;
    using System.Web;
    public class Handler : IHttpHandler
    {
    	public void ProcessRequest(HttpContext context) {
    		context.Response.ContentType = "text/plain";
    		string postData = context.Request.Form[0];
    		context.Response.Write(postData);
    	}
    	
    	public bool IsReusable {
    		get { return true; }
    	}
    }
    In case of ext-base adapter an exception is thrown because the HttpHandler doesn't see posted data (fails on context.Request.Form[0] - index out of range). In case of YUI adapter the response is coming back just fine. See Response tab in Firebug.
    BTW, this worked fine in v2.0.2.

    Thank you.

  3. #13
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default

    Hi, I think the 'bug' can be on the YIU adapter.
    I'll try to explain:

    With 2.1 ext version, there is a change when sending jsonData on an ajax request about the content-type.
    • - Before 2.1 ,it was setted to "application/x-www-form-urlencoded; charset=UTF-8".
    • - In 2.1 version by default, when you send json data, it is setted to "application/json" what is more standard and more appropiate... it is a json request not a form request.


    Also, at your server side code, you are trying to read the first form in the request (context.Request.Form[0]), but in this type of request (json) , doesn't exist any form.

    With YUI-adapter, you can see in firebug that the content-type is "application/x-www-form-urlencoded; charset=UTF-8"... that's the reason it works... and that's the reason I think the bug can be on this adapter...

  4. #14
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default

    halkon_polako

    Thank you very much, bud, you're absolutely right!!! All I had to do is read raw post data.
    Guys, consider this topic closed again

Page 2 of 2 FirstFirst 12

Posting Permissions

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