如何设置内容类型URL编码

时间:2015-09-24 11:32:36

标签: codeigniter api rest

我正在使用代码点火器REST API。如何在ajax post中将内容类型设置为x-www-form-urlencoded。我试过: -

jQuery.ajax ({
url: myurl,
type: "POST",
data: JSON.stringify({ "user_name": "testuser", "user_password": "1234" }),
dataType: "json",
contentType: "x-www-form-urlencoded; charset=utf-8",
success: function(){
    alert('success');
}
});

总是得到错误的请求错误。我不能将值发布到控制器,除非值是url编码的。我需要在任何内容类型中发布值。如何可能?是客户端还是服务器端问题?

0 个答案:

没有答案