Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AJAX http后期编码问题_Javascript_Ajax_Encoding - Fatal编程技术网

Javascript AJAX http后期编码问题

Javascript AJAX http后期编码问题,javascript,ajax,encoding,Javascript,Ajax,Encoding,我在我的ajax帖子中遇到了关于åäö字符的问题。 这是我的代码: $.ajax({ type: 'POST', encoding: "UTF-8", dataType: 'text', url: JSurl + "/Home/UpdateCustomerData", data: "jsonDat

我在我的ajax帖子中遇到了关于åäö字符的问题。 这是我的代码:

 $.ajax({
                    type: 'POST',
                    encoding: "UTF-8",
                    dataType: 'text',
                    url: JSurl + "/Home/UpdateCustomerData",
                    data: "jsonData=" + JSON.stringify({ customer: '@Model.name', name: names[activeService], data: JSON.stringify(dataToSend) }),
                    success: function (returnPayload) {
                        //If last component, redirect to customer view
                        if (KomponentCountTotal == KomponentCountDone) {
                            window.location.href = JSurl + '/Home/Customer?name=' + '@Model.name' + '&index=0';
                            return;
                        }


                        console && console.log("request succeeded");
                        $('#buttonDiv' + index + '').append('<div id="success" class="col-lg-12"><br /><br /><div class="alert alert-success">Sparat!</div></div>');
                        $('#success').delay(1500).fadeOut(1000, function () { $(this).remove(); });
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        console && console.log("request failed");
                        $('#buttonDiv' + index + '').append('<div id="fail" class="col-lg-12"><br /><br /><div class="alert alert-danger">Något gick fel!</div></div>');
                        $('#fail').delay(1500).fadeOut(1000, function () { $(this).remove(); });
                    },

                    processData: false,
                    async: false
                });
$.ajax({
键入:“POST”,
编码:“UTF-8”,
数据类型:“文本”,
url:JSurl+“/Home/UpdateCustomerData”,
数据:“jsonData=“+JSON.stringify({customer:'@Model.name',name:names[activeService],data:JSON.stringify(dataToSend)}),
成功:功能(返回有效载荷){
//如果是最后一个组件,则重定向到客户视图
如果(KomponentCountTotal==KomponentCountDone){
window.location.href=JSurl+'/Home/Customer?name='+'@Model.name'+'&index=0';
返回;
}
console&&console.log(“请求成功”);
$('#buttonDiv'+index+'').append('

Sparat!'); $('#success').delay(1500).fadeOut(1000,函数(){$(this.remove();}); }, 错误:函数(xhr、ajaxOptions、thrownError){ console&&console.log(“请求失败”); $(“#buttonDiv”+index+”).append(“

Något gick fel!”); $('#fail').delay(1500).fadeOut(1000,函数(){$(this.remove();}); }, processData:false, 异步:false });
例如,如果我的@Model.name是“Röd”,那么我的控制器将以jsonData的形式接收
“{\”customer\:\“R”


如何解决此问题?

您是否在html中设置了正确的元标记

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

是的,我有那套。