Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts

    how to retrieve chinese,japan, rusia,arabic character using jquery from database?

    hello....first I can retrieve chinese,rusia,arabic from database without jquery or ajax.... but when I retrieve chinese,rusia,arabic from database using jquery or ajax it couldn't

    Code:
    function getdata(str)
    {
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","data.php?a="+str,true);
    xmlhttp.send();
    }
    Code:
    <script type="text/javascript">
    $(document).ready(function() {
    
    
    	$('#Form').submit(function() {
    		$.ajax({
    			type: 'GET',
    			url: $(this).attr('action'),
    			data: $(this).serialize(),
    			success: function(data) {
    				$('#data').html(data);
    			}
    		})
    		return false;
    	})
    })
    
    
    </script>

    ...... I have used accept-charset="UTF-8" in form and meta content="text/html;charset=utf-8" but still failed....
    Last edited by ankifreeze; 03-02-2011 at 02:41 PM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    You should tell $.ajax the contentType of the received data
    Code:
    $.ajax({
       ...,
       contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
       ...
    });
    And you should output the characters from the script/page of the "action" attribute using something like this (PHP example):
    Code:
    <?php header('Content-Type: text/html; charset=UTF-8'); ?>

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    You should tell $.ajax the contentType of the received data
    Code:
    $.ajax({
       ...,
       contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
       ...
    });
    And you should output the characters from the script/page of the "action" attribute using something like this (PHP example):
    Code:
    <?php header('Content-Type: text/html; charset=UTF-8'); ?>
    hello...I have resolved my problem....I put charset="utf-8" in
    Code:
    <script type="text/javascript" src="jquery-1.3.2.min.js" charset="utf-8"></script>
    and I set configuration on mysql default-character-set=utf8
    character-set-server = utf8
    collation-server = utf8_general_ci

    thanks for help me....


  •  

    Posting Permissions

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