我在客户端有外国人欧元标志。我将此参数转换为 json,然后通过 json 发送到 PHP 后端。
问题是在服务器端角色被破坏了
campaignsJson.campaigns[i] ={};
campaignsJson.campaigns[i].advertiser_id = advertiserId;
campaignsJson.campaigns[i].sign_id = sign_id;
var campaignsJsonstringify = JSON.stringify(campaignsJson);
alert(campaignsJsonstringify); // THE eruo sign is ok
//send via form
$.sendPost = function() {
var campaignsJsonstringify = JSON.stringify(campaignsJson);
$('#campaigns_json').val(campaignsJsonstringify);
document.getElementById("container_send").submit();
}
<form id="container_send" action="campaigns_action.php" method="post">
<input type="hidden" id="campaigns_json" name="campaigns_j" value=""/>
</form>
//PHP
if($_SERVER['REQUEST_METHOD'] == "POST") {
$isError = false;
if($_POST['campaigns_j'])
{
$campaigns_json = $_POST['campaigns_j'];
echo $campaigns_json;
//Here is the foreigner euro sign is printed as gibrish
}
}
我需要有效字符串的字符串并将其前言给第三方 API
,为此我需要保持从客户端发送的字符串有效。