开发者

Problem of accents with jQuery AJAX and oracle database

I have a problem with charset on a php script using jQuery for AJAX and an Oracle database. When i'm using a web form to send update queries through Ajax with jQuery, my accents characters seem to be sent in UTF8 and they are not good in the database. I don't understand because i have no UTF-8 definition in any part of my code.

Can someone help ? here are the differents parts of code :

i have a Oracle database with NLS_DATABASE_PARAMETERS : NLS_CHARACTERSET=WE8MSWIN1252

Web page meta :

Here is the jQuery :

$.ajaxSetup
    ({
        'beforeSend' : function(xhr) 
        {
            if (xhr.overrideMimeType!=undefined)
            {
                xhr.overrideMimeType('text/html; charset=ISO-8859-1');
            }
        }
    });
$('input.f_req_field').change(function ()
    { 
        var p=$(this).attr("name");
        var v=$(this).attr("value");
        $.post("index.php", { mode:"ajax_update", param: p, valeur: v } 
                ,
                    function(data){
                    //alert("Data Loaded if no errors here : 开发者_开发知识库" + data);
                    },"html"
                );

Connection to the database in php is :

$link=oci_connect($user,$pass,$host,"WE8ISO8859P1");

Query launch is :

$result_tmp = oci_parse($link,$req ) OR print("Error" );  
$tmp= oci_execute($result_tmp,OCI_COMMIT_ON_SUCCESS); 

Thanks


you should set you ajax request charset in ajax setup,


$.ajaxSetup({
    type: "GET",
    cache: false,
    timeout: 10000,
    scriptCharset: "UTF-8", //replace UTF-8 with yours
    contentType: "application/x-www-form-urlencoded; charset=UTF-8"  //replace UTF-8 with yours
});

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜