Results 1 to 6 of 6

Thread: Ext.Ajax.request header problem

  1. #1

    Default Ext.Ajax.request header problem

    Hi,

    I have all my html pages using the iso-8859-1 charset, so, I have to use in my Ajax requests, this charset too.

    My code looks like this :
    Code:
                        Ext.Ajax.request({
                            url: '/perl/Parametrage/elementGestion_extjs.pl'
                            ,method: 'POST' 
                            ,jsonData: {'name' : 'nimportequoi '}
                            ,defaultHeaders: {
                                'Content-Type': 'application/json; charset=iso-8859-1'
                            }
    Well, the problem is, that in firebug I found always the value 'application/json; charset=UTF-8' for the request header.
    I've also tried to set headers property of Ext.Ajax.request and the defaultHeaders property for Ext.Ajax global or Ext.lib.Ajax.

    I've tried too to debug to see where the header is changed, couldn't figure out either.

    The real problem is that I have to post some latin characters ( ...) but I found them in the request string as 'é' 'è' or ' '

    I see that Ext.encode doesn't change these values, in Firebug the postData value passed to the XmlHttpRequest object seems all right.

    I use Ext 3.2

    Any idea is welcome.

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    http://www.w3.org/TR/XMLHttpRequest/#the-send-method

    It encodes using UTF-8

    Doesn't matter how the server originally encoded the characters of your HTML page.

  3. #3

    Default

    In fact, it seems that the charset problem is not due to ExtJS, I have the same problem if I create the XMLHttpRequest object myself. But I still can't see how to solve the problem.

  4. #4

    Default

    Quote Originally Posted by Animal View Post
    http://www.w3.org/TR/XMLHttpRequest/#the-send-method

    It encodes using UTF-8

    Doesn't matter how the server originally encoded the characters of your HTML page.
    Right, didn't see your answer

  5. #5

    Default

    Quote Originally Posted by Animal View Post
    http://www.w3.org/TR/XMLHttpRequest/#the-send-method

    It encodes using UTF-8

    Doesn't matter how the server originally encoded the characters of your HTML page.
    Well, it seems that the only solution I have is to escape all characters posted to server and unescape them there. Not quite elegant.

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Just get your server to behave itself!

    The XHR will send

    Code:
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    So the server should know how to decode the byte stream back into characters.

Similar Threads

  1. add a param to all Ext.Ajax.request (tree, store, normal Ajax.request)
    By aj3423 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 26 Jan 2010, 9:18 AM
  2. An easy way of changing the AJAX header request header
    By dotnetCarpenter in forum Community Discussion
    Replies: 11
    Last Post: 4 Oct 2007, 12:01 PM
  3. Problem in send ajax request :The Ext.Ajax is null or not Object
    By flyingpig in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 27 Aug 2007, 11:29 PM
  4. Replies: 4
    Last Post: 27 Jun 2007, 2:31 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
  •