CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Unhappy AJAX encoding problem

    Hallo

    i have encoding problem in AJAX , it seems that it doesnt support multilanguage , i m trying to display Arabic text and i got '????'

    how can i solve this problem

  2. #2
    Join Date
    Aug 2005
    Location
    Milwaukee, WI
    Posts
    55

    Re: AJAX encoding problem

    I'm not quite sure what you're trying to say here.

    AJAX in and of itself doesn't support anything. It's just a design pattern that encompasses many technologies. If you are using Client-Side and Server-Side languages you are familiar with nothing changes. The only thing that changes when using AJAX is how requests are made to your server.

    Can you be more specific as to your issue?

  3. #3
    Join Date
    Mar 2000
    Location
    Vancouver, BC, Canada
    Posts
    278

    Re: AJAX encoding problem

    go into your html source code for the page.

    look for a meta tag that says somthing like:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    iso-8859-1 is english. you will need to look up what the character set for Arabic is and simply replace the iso-8859-1 with the new value that will tell the browser to expect the new character set and display it accordingly. this goes for all language types outside of normal browser expectations (chinese, japanese...)
    David Meikle
    Quantum Unit Solutions, LLC
    www.quantumunit.com

  4. #4
    Join Date
    Nov 2007
    Posts
    1

    Re: AJAX encoding problem

    Quote Originally Posted by life_maker
    Hallo

    i have encoding problem in AJAX , it seems that it doesnt support multilanguage , i m trying to display Arabic text and i got '????'

    how can i solve this problem
    AJAX encoding problem

    can u fix it ajax encoding problem because i have same problem like you
    if you have any solution please reply me at maqsoodamd@gmail.com

    i m very thanks ful you in advance

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: AJAX encoding problem

    Welcome to the forums, maqsoodamd. Please note that the thread you posted on is over a year old and by a person who never came back to the forum. It is possible that you will not see a reply. Whenever you have a problem, please create a new thread and explain your problem in detail. Thanks!
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  6. #6
    Join Date
    Nov 2007
    Posts
    1

    Smile Re: AJAX encoding problem

    Yes I too was held with the same problem , with ASP ans AJAX.
    At last i found it

    I added the ASP code

    <% response.Charset="windows-1256" %>

    as the first line in the processing page which is requested by XmlHttpRequestObject.
    Hope u got it.

    Good Luck

    IHN

    Quote Originally Posted by maqsoodamd
    AJAX encoding problem

    can u fix it ajax encoding problem because i have same problem like you
    if you have any solution please reply me at maqsoodamd@gmail.com

    i m very thanks ful you in advance

  7. #7
    Join Date
    Apr 2009
    Posts
    1

    Unhappy AJAX charset problem

    Dear All,
    Since I was having trouble with AJAX charset encoding today in the morning with refresh mind I found the solution, the reason why I am posting here is , I searched 2 whole days to find a solution from forums, etc but I could not. however now I am lucky to find the solution for any language just using utf-8 first let mi write my ajax
    My Ajax code is like below:
    not:you can save below code to a page like ajax_post.js

    Code:
    var xmlhttp_sp = false;
    
    try {
    //If the Javascript version is greater than 5.
    xmlhttp_sp = new ActiveXObject(”Msxml2.XMLHTTP”);
    
    } catch (e) {
    //If not, then use the older active x object.
    try {
    
    xmlhttp_sp = new ActiveXObject(”Microsoft.XMLHTTP”);
    
    } catch (E) {
    //Else we must be using a non-IE browser.
    xmlhttp_sp = false;
    }
    }
    
    if (!xmlhttp_sp && typeof XMLHttpRequest != ‘undefined’) {
    xmlhttp_sp = new XMLHttpRequest();
    
    }
    
    function makerequest_sp(serverPage, params, objID)
    {
    var myRandom=parseInt(Math.random()*99999999);
    
    params+=’&’+myRandom;
    
    var url = serverPage;
    //var params = “lorem=ipsum&name=binny”;
    xmlhttp_sp.open(”POST”, url, true);
    //Send the proper header information along with the request
    xmlhttp_sp.setRequestHeader(”Content-type”, “application/x-www-form-urlencoded; charset=UTF-8″);
    xmlhttp_sp.setRequestHeader(”Content-length”, params.length);
    xmlhttp_sp.setRequestHeader(”Connection”, “close”);
    xmlhttp_sp.onreadystatechange = function() {//Call a function when the state changes.
    if(xmlhttp_sp.readyState == 4 && xmlhttp_sp.status == 200) {
    document.getElementById(objID).innerHTML = xmlhttp_sp.responseText;
    //alert(xmlhttp_sp.responseText);
    }
    }
    xmlhttp_sp.send(params); 
    
    //xmlhttp_sp.send(null);
    }
    before I was using AJAX with GET method but when I GET form values in my language (farsi Afghanistan) it was just ???? and after using above ajax code I solved my problem.

    Code:
    //some comments
    function makerequest_sp(serverPage, params, objID)
    when you wanna call makerequest_sp it takes 3 params
    1.serverPage like test.php
    2.params the values of a form like name=nasir&id=34& …
    3.objID is div id where you want to show xmlhttp_sp.responseText inside a div.

    how you call this let me write a function how did I call

    Code:
    function test_dari(formid)
    {
    var formvalues = do_it(formid);
    //this do_it function will retrieve all form name with its value
    url=’test.php’;
    var params=formvalues+’action=getform&’
    makerequest_sp(url, params, ‘mytest’); //here is ajax call function
    }
    any help you want please write to me.
    naser@netlinks.af
    Last edited by PeejAvery; April 16th, 2009 at 08:40 AM. Reason: Added code tags.

  8. #8
    Join Date
    May 2002
    Posts
    10,943

    Re: AJAX encoding problem

    Welcome to the forums, nasirgulzade.

    Please remember to keep your posts relevant. This thread is originally 3 years old.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured