【问题标题】:Problem of accents with jQuery AJAX and oracle databasejQuery AJAX 和 oracle 数据库的重音问题
【发布时间】:2011-06-20 12:33:46
【问题描述】:

我在使用 jQuery for AJAX 和 Oracle 数据库的 php 脚本上遇到字符集问题。 当我使用 Web 表单通过 Ajax 和 jQuery 发送更新查询时,我的重音字符似乎以 UTF8 格式发送,并且它们在数据库中并不好。我不明白,因为我的代码的任何部分都没有 UTF-8 定义。

有人可以帮忙吗?这是代码的不同部分:

我有一个带有 NLS_DATABASE_PARAMETERS 的 Oracle 数据库:NLS_CHARACTERSET=WE8MSWIN1252

网页元数据:

这里是 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"
                );

连接到php中的数据库是:

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

查询启动是:

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

谢谢

【问题讨论】:

    标签: php jquery oracle character-encoding


    【解决方案1】:

    你应该在 ajax 设置中设置你的 ajax 请求字符集,

    $.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 });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-11
      • 2016-05-03
      • 1970-01-01
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      相关资源
      最近更新 更多